Hi,
I'm using WinCC OA 3.14 under Linux (Open SuSE).
I have been trying to change a checkbox's text on runtime and found and interesting quirk.
My test project was created with three languages.
At design time, when I want to set different values for different languages, I just change the language @Gedi (using the combobox on the toolbar), and then doubleclick the checkbox, and edit the messages for that language.
At runtime, I can't figure out how to set the text for the checkbox: whenever I try to:
setValue("mycheckbox", text, "Value to display");
The only text affected is the one for the first language of the project (English) so, if the language is changed for example to Spanish, the original design-time value for Spanish is shown, and not the one set via setValue.
Tried this way, but does not work, also:
dyn_string myValues;
// could use getLangIdex but it's not the point here
myValues[1] = "English";
myValues[2] = "Spanish";
myValues[3] = "Other";
langString myLangString = myValues;
setValue("mycheckbox", text, myLangString);
The text changes only for the first language.
Any hints or ideas? Is it even possible to change the combobox text values at runtime taking multilanguage into account?
Thank you!
Dynamic change of checkbox multilingual text
- a.decelis
- Posts:30
- Joined: Thu Jun 25, 2015 6:42 pm
Dynamic change of checkbox multilingual text
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Dynamic change of checkbox multilingual text
The text property in checkbox and radiobutton for scripting is just a string, not a langString, therefore you can only set the text for the current active language. If you want to switch the text whenever the active language changes, do the setValue() inside the LangChanged() script.
- a.decelis
- Posts:30
- Joined: Thu Jun 25, 2015 6:42 pm
Re: Dynamic change of checkbox multilingual text
Edit2:
I have tried this:
Under a pristine installation of WinCC OA 3.14, under Windows 7 (my other tests where under Open SuSE).
In a project with two different languages:
This is the output I get when changing languages back and forth:
So, definitely, dynamic language changing is not working for me.
[hide]
I have tried this:
Code: Select all
main() //LangChanged
{
DebugN(getActiveLang(), getLocale(getActiveLang()));
}In a project with two different languages:
This is the output I get when changing languages back and forth:
Code: Select all
WCCOAui1:[0]["en_US.utf8"]
WCCOAui1:[0]["en_US.utf8"]
WCCOAui1:[0]["en_US.utf8"][hide]
[/hide]Edit1:
Yes, I found (part of) the problem.
getActiveLang()
Always returns 0 in my project. As I have been fiddling with languages:
[...]/nls/lang.dir
Added
10099 eu_ES.utf8 106 # Basque, Basque Country
[...]/nls/lang.linux
Added
10099 eu_ES.utf8 # Basque, Basque Country
[...]/msg/en_US.utf8/trans.cat
Added
eu_ES.utf8,Basque - Basque Country
I don't know if I've broken the runtime language support. I'm going to try it on another, pristine installation and see what happens.
Edit:
the error lies here. getActiveLang() returns an 0 based integer, and I am not checking the return value.Code: Select all
string locale = getLocale(getActiveLang());
I'll post here when I get it solved.
Hi,
thank you very much for your suggestion. In fact, I already had tryed doing that, but: changing text inside the LangChanged event seems to change ONLY the text for the first language of the project (English).
So, if a language change is triggered, the new text is displayed for English only: choosing any other language than the first, the CheckBox will show what ever text was entered at design time.
A snippet of what I am doing.
Perhaps is just not possible to change language for CheckBox items at runtime. :huh:Code: Select all
main() // LangChangedEvent { string locale = getLocale(getActiveLang()); string text = "My Text"; string suffix = $SUFFIX; // TODO move to catalogs and use getCatStr() switch (locale) { case "es_ES.utf8": text = "Spanish text"; break; // ... } CHEKBOX.text(0, text + " " + suffix); }
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Dynamic change of checkbox multilingual text
How did you switch languages ?
Note that the language combobox in a Vision module does NOT change the active language!
It just switches the displayed language for langString objects and can be used for quick tests, set per module.
But there is only ONE manager global active language, which is not changed with it.
You must use the CTRL function switchLang()
Note that the language combobox in a Vision module does NOT change the active language!
It just switches the displayed language for langString objects and can be used for quick tests, set per module.
But there is only ONE manager global active language, which is not changed with it.
You must use the CTRL function switchLang()
- a.decelis
- Posts:30
- Joined: Thu Jun 25, 2015 6:42 pm
Re: Dynamic change of checkbox multilingual text
Thanks Martin!
Now it makes much more sense.
I'll post here with the results, whenever I can fix it.
Thanks again!
Now it makes much more sense.
I'll post here with the results, whenever I can fix it.
Thanks again!