-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a combobox that let the user pick which language he wants the application to be, there are 4 available.
The combobox list the following message : "See the application in English" in the different language. The message being translated.
At the moment I've 4 properties in my main zk-labels.properties, one for each language.
However i would much prefer having only 1 properties in each of zk-labels-language.properties file. And just loop through those to populate the combobox.
Is it possible?
Hello
You can do something like this
Combobox languageChangeCombo=new Combobox();
LabelLoader internalLabelLoader = new LabelLoader();
String[] mySupportedLocales={"en","ja","it"}; //Can load from properties files the supported language
String myLabelKey="language.change.message";
for (int i = 0; i < mySupportedLocales.length; i++) {
String supportedLocaleStr = mySupportedLocales[i];
Locale supportedLocale=new Locale(supportedLocaleStr);
String localeMessage=internalLabelLoader.getLabel(supportedLocale, myLabelKey);
Comboitem comboitem=new Comboitem();
comboitem.setLabel(localeMessage);
comboitem.setValue(supportedLocale);
comboitem.setParent(languageChangeCombo);
}
It will create a combobox with all languages.
Harish
How about something like this?
file label.properties
stringCollection=string1,string2,string3,string4
// 1. Load this string in run time
String stringCollection = Labels.getLabel("stringCollection");
// 2. Split into a list or array
String[] allString = stringCollection .split();
// 3. Assign it into Combobox
combobox.setModel(allString);
Asked: 2015-04-16 09:57:58 +0800
Seen: 38 times
Last updated: Apr 17 '15