• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Internationalization

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am implementing internationalization in my appliction.it should support 4 languages so i am wtriting 4 property files. that property file specification iam doing in my struts_config.xml when i do that it will take only last property file entrys.my property file specificatiopn as follows.
what to do to take all entries of property file.

<message-resources parameter="com.trims.resources.TRIMSMessageResources"/>
<message-resources key="label" parameter="com.trims.resources.TRIMSLabelResources"/>
<message-resources key="message" parameter="com.trims.resources.TRIMSMessageResources"/>
<message-resources key="image" parameter="com.trims.resources.TRIMSImageResources"/>
<message-resources parameter="com.trims.resources.TRIMSLabelResources_it"/>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can only specify one message resource without a key attribute. All others must have a key attribute.

It's also important to understand that you only need to define the base bundle name. You do not need to define a separate bundle for each language. Even though you have both a TRIMSLabelResources.properties file and a TRIMSLabelResources_it.properties file, you only need to define TRIMSLabelResources in the struts-config.xml file. Struts will automatically find the file with the correct language suffix.
 
rajani arjun
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thank you for reply . but what your telling iam not getting can you tell me clearly with example.if possible attaching some lines of coding

thankyou
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajani,
What Merrill has pointed out, is that there has to be a key for all the Properties file. Only one can be left without a key. For your example..They need to be given if you have differnt .properties files.

<message-resources parameter="com.trims.resources.TRIMSMessageResources"/>
<message-resources key="label" parameter="com.trims.labels.TRIMSLabelLabels"/>
<message-resources key="message" parameter="com.trims.messages.TRIMSMessageMessages"/>

In case you want i18n, you need to give only the default file name and the others would be found by Struts for the reqisuite language.
Struts-config.
<message-resources parameter="com.abc.efg.TRIMSMessageResources" />
You dont have to define.TRIMSMessageResources_fr, TRIMSMessageResources_sp for that.
Hope it is clear.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link explains all this in more detail.

What I'm trying to tell you is that you need to remove the following line from your struts-config.xml file.

<message-resources parameter="com.trims.resources.TRIMSLabelResources_it"/>

Only the base name (TRIMSLabelResources) should be defined here, and not language specific names (TRIMSLabelResources_it). I don't know how to explain it any more clearly than that.
 
rajani arjun
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got it. but one doubt other property files which we are writting for other language it should be their is it . but only thing is we will not specify in property file.

one morething want to ask, write now what i am doing is changing language in the internet explorer then my application will change to corresponding language. what i want to do is without internet explorer settings (In IE let it be default language)i want to set my language from program, that language should come how to do that.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I think you have the concept. You have multiple .properties files with language-specific suffixes (_en, _it, _es, _fr, etc.) but you only have one entry in the struts-config.xml file.

As for your question about how to dynamically set the language, see my response in this thread.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an example on Struts internationalization you can refer here.

Struts I18N using locale.
Struts Internationalization using browser settings.

regards
Struts Developer
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi if you still not able to apply internationalization, please feel free to email to this ID(krishnaathul@gmail.com). I will sent you you an example app
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic