I have made a server application and now i want it to support multiple languages. I have looked over the net and found that solution is properties file.
Now i have the next problem, while i can change jsf pages via messages, i want also to change the language of my hardcoded strings in source file also using this same properties file. Can this be accomplished?
Let me be more clear - I have JSF page and a bean behind it. Some of the content of the page is adjusted dynamically by methods of the bean, eg i wite some text to the page. I also want that text to be language dependent.
Dieter Quickfend wrote:
where certainI18nString is a property in your backing bean containing your internationalized string.
I want all my strings to be in .propeties file - the ones i hardcoded in .java files, and the ones i use on jsf pages. I dont want to have something in .properties file(for static jsf values) and something in other txt file (for values that bean returns that are shown on the page).
its like this:
First is static value user that is same for all users. Second is country of origin of user which can be different for every user. If we have user named Bob, from England, following would be written for him:
If we switch language to Italian it sholud write:
And both of these words should be in .properties file.
- put ALL your translatable text into a message properties file
- import your properties file into the JSF page with the <f:loadBundle> tag
- anywhere you want to display the text from the properties bundle, use the <h:outputText> tag
That would print out a translated "user" string, and then the value of the beans "country" straight from the bean.
If you also wanted to translate the country (as you did in your example), you would have to make the country stored in the bean a country code to look it up in the properties file.