wood burning stoves 2.0*
The moose likes Struts and the fly likes internationalization & Properties file order (gone south) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "internationalization & Properties file order (gone south)" Watch "internationalization & Properties file order (gone south)" New topic
Author

internationalization & Properties file order (gone south)

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
I had an idea last night which has not worked out so well for me. The idea was to break my property files into different areas so they are more manageable. Somebody smack me for trying to make life easier.

The idea was change the struts.xml to break my properties files into folders for display language and titles / meta tags so I changed my file structure and struts.xml to:

<constant name="struts.custom.i18n.resources"
value="properties/languages/Language,
properties/languages/Language_fr,
properties/metatags/Language-Meta,
properties/metatags/Langauge-Meta_fr" />

Language, my fall back properties in case nothing is found is english. Problem is now that I have changed this structure everything comes up French. My fall back properties are no longer working. No matter what I set my browser language for it always comes up French.

Why does the default fallback language file no longer work? If I set my browser for chineese it comes up french.

I would really like to have multiple properties files so that say english would have a properties file for body content & menus, well you get the idea. As it stands now looks like I have to have everything in one huge language file instead of making smaller more manageable areas.

HELP PLEASE ITS AN EMERGENCY... just kidding guys its not really. Its just bugging me. LOL I crack myself up.

Cheers,
Earl
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Additional information:

This worked fine when I had Language.properties & Language_fr.properties in my classes root. Now that I have tried modify, make more manageble and tidy my properties file no matter what country I select for a language my fall back properties file is never found and French is always displayed.

There has got to be something stupid here Im missing. I have attached a screen shot of my directory structure & here is my struts.xml



Does anyone know why when I made the directory changes that struts will not fall back to the Language.properties? I would bet money that I could solve this not showing english by renaming Language.properties to Language_en.properties but then what would be my fall back properties file if _en or _fr was not found?

cheers,
Earl




[Thumbnail for directoryStructure.jpg]

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
I've cleared my jboss cache and the site still keeps coming up french no matter what I set my browser to.

Obviously I am missing a basic understanding of how properties files work. My goal is to have multiple language properties files so that I can say hold menu languages in one properites file and body content in another. I think this would make multiple languages and areas of the site easier to manage instead of having 1 HUGE properties file for each language.

Anyone have an idea on how this would be best managed and why everything comes up french on my site?

earl
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
on the advice of someone here I tried to load up my site without mapping everything to struts.custom.i18n.resources. I basically took the struts.custom.i18n.resources mapping I provided earlier and removed. That does not work no i18n mappings are found

I think because I am trying to do a custom directory structure and *.properties are not swinging off the class root you must tell struts where the properties files are at by using an implicid mapping

I still cannot figure out why though that the site always comes up with the properties for _fr. Its obvious struts is seeing the mapping. Why is my fallback properties file (english) Languages.properties not being found no matter what language I set my browser for?

I have tried renaming my language file to Language_en.properties and not having a fall back properties file. No matter what I do every thing comes up french. So weird.

I tried changing my mappings to this:


browser setting snap shot is attached. have no idea why it only sees _fr

earl



[Thumbnail for languages.jpg]

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Can anyone help me with i18n? Ive done some further tests and if I just leave my default two language files in the cofiguration:



Then If I remove "Language_fr.properties". If I select french for my browser settings my languages should fall back to Language "Language.properties".

It does not it shows all the labels as literals. If I set my browser for english the default Language file "Language.properties" labels are shown fine.

I dont understand this behavior. It doesnt follow everything I have read about how property files should work. My is the properties file should be searched something like this.

Language.properties -- default properties file
Language_fr.properties -- default fallback for french
Language_fr-CA.properties -- file for french canadian users.

My understanding is some one browsing to a site with these properties files using say en-AU or some such the engine should start looking for everthing after _ in the properties files so in this case it should be a fallback to a default Language.properties file.

earl
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Here is the solution I came up with for breaking out the properties files so they fall back correctly to the default language when using custom folders.



Note that my fall back languages do not have *.properties in the struts.custom.i18n.resources definition. This will make them fall back to your default language. If you define properties/languages/Language as properties/languages/Language.properties in this xml example then french language will always come up as default.

I have attached a screen shot of the directory that houses my Language.properties & Language_fr.properties so you can see how I got it to fall back to the default language instead of always bringing up French instead of my fall back.




[Thumbnail for languages.png]

 
 
subject: internationalization & Properties file order (gone south)
 
Similar Threads
Bilingual display question
Internationalization:is language selected according to client, or server?
unicode encoding vs property files
Quality of English
Struts 2.1.8 validation.xml & internationalization