This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
Yes you can use properties file for multi language, but in that case you have to pick all text from properties file, dont wtite any text direct in source file.
Joined: Feb 03, 2011
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.
How do i pick that text from properties file?
Joined: Sep 08, 2010
So i think you need to use some langugae convertor, which convert your text onthe fly and display that on your pgae, Propertis file only use when you have fixed text.
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.
Joined: Feb 03, 2011
I also did some research of my own in the meantime and i found quite good tutorial: