How to get a label value for all the different international label file?

asked 2015-04-16 09:57:58 +0800

WilliamB gravatar image WilliamB
1609 1 6

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?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-04-17 01:47:53 +0800

echarish gravatar image echarish flag of Japan
1809 7


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();

It will create a combobox with all languages.


link publish delete flag offensive edit

answered 2015-04-16 10:27:35 +0800

roliroli gravatar image roliroli
164 4

How about something like this?

file label.properties


// 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


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-04-16 09:57:58 +0800

Seen: 38 times

Last updated: Apr 17 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More