--- a/svghmi/i18n.py Tue Feb 09 08:11:22 2021 +0100
+++ b/svghmi/i18n.py Tue Feb 09 17:09:08 2021 +0100
@@ -15,6 +15,11 @@
+# to have it for python 2, had to install +# https://pypi.org/project/pycountry/18.12.8/ +# python2 -m pip install pycountry==18.12.8 --user """ Opens PO file with POEdit """
@@ -92,7 +97,18 @@
translated_messages.append((msgid,translated_message))
for lang,translation in translations:
+ language_name = pycountry.languages.get(alpha_2 = l).name + country_name = pycountry.countries.get(alpha_2 = c).name + langs.append("{} ({})".format(language_name, country_name)) + language_name = pycountry.languages.get(alpha_2 = lang).name + langs.append(language_name) for msgid, msg in translation.iteritems():
--- a/svghmi/i18n.ysl2 Tue Feb 09 08:11:22 2021 +0100
+++ b/svghmi/i18n.ysl2 Tue Feb 09 17:09:08 2021 +0100
@@ -20,7 +20,7 @@
const "translations", "ns:GetTranslations($translatable_strings)";
+ > var langs = [ "default", foreach "$translations/langs/lang" {
if "position()!=last()" > ,
--- a/svghmi/widget_dropdown.ysl2 Tue Feb 09 08:11:22 2021 +0100
+++ b/svghmi/widget_dropdown.ysl2 Tue Feb 09 17:09:08 2021 +0100
@@ -337,11 +337,17 @@
labels("text box button highlight");
// It is assumed that list content conforms to Array interface.
- /* TODO : Support HMI:List */
- ``foreach "arg" | "«@value»",
+ // special case when used for language selection + when "count(arg) = 1 and arg[1]/@value = '#langs'" { + foreach "arg" | "«@value»", --- a/tests/svghmi_i18n/svghmi_0@svghmi/svghmi.svg Tue Feb 09 08:11:22 2021 +0100
+++ b/tests/svghmi_i18n/svghmi_0@svghmi/svghmi.svg Tue Feb 09 17:09:08 2021 +0100
@@ -2418,19 +2418,25 @@
inkscape:current-layer="hmi0"
- inkscape:cx="826.76877"
- inkscape:window-width="1431"
+ inkscape:cx="1015.4336" + inkscape:cy="539.83485" + inkscape:window-width="1939" inkscape:window-height="844"
- inkscape:window-x="3841"
+ inkscape:window-x="3325" + inkscape:window-y="554" inkscape:window-maximized="0"
inkscape:guide-bbox="true"
inkscape:snap-global="true"
inkscape:snap-bbox="true"
- inkscape:bbox-nodes="true" />
+ inkscape:bbox-nodes="true"> + inkscape:locked="false" /> style="color:#000000;fill:#ffffff"
@@ -2554,16 +2560,16 @@
- inkscape:label="HMI:DropDown:orig:fr_FR:sl_SI@lang"
- transform="matrix(0.81491208,0,0,0.81491208,32.392121,-516.64521)"
+ inkscape:label="HMI:DropDown:#langs@lang" + transform="matrix(0.81491208,0,0,0.81491208,92.392121,-676.64521)" style="stroke-width:0.35083869">
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#53676c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.75419343;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
@@ -2571,31 +2577,31 @@
inkscape:label="highlight"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.75419331;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#d42aff;fill-opacity:1;stroke:none;stroke-width:0.35083869px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.95956421px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#d42aff;fill-opacity:1;stroke:none;stroke-width:0.35083869px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" inkscape:label="text"><tspan
style="text-align:start;text-anchor:start;fill:#d42aff;stroke-width:0.35083869px"
- id="tspan421">sel_0</tspan></text>
+ id="tspan421">Language (Country)</tspan></text> style="opacity:1;vector-effect:none;fill:#a7a5a6;fill-opacity:1;stroke:none;stroke-width:0.12376806;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ sodipodi:cx="1387.0236" + sodipodi:cy="977.31356" sodipodi:arg1="1.5707963"
@@ -2603,7 +2609,7 @@
inkscape:flatsided="false"
- d="m 1200.5,1018.6835 -18.9155,-32.76262 -18.9155,-32.76264 37.831,0 37.831,0 -18.9155,32.76264 z"
+ d="m 1387.0236,1020.9971 -18.9156,-32.76268 -18.9155,-32.76264 37.8311,0 37.831,0 -18.9155,32.76264 z" inkscape:transform-center-y="10.92088"
inkscape:label="button" />