• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Internationalization and Word Order

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have an internationalized String that takes the following format:

Returned results for "PLACEHOLDER" in:

where PLACEHOLDER is something dynamic that is returned from a data store and is already internationalized.

I was thinking that I could have two keys in a properties file:

1) returned=Returned results for
2) returned.part.two=in:

The problem is that I know that word order can vary in different languages (English, Spanish, etc) and that it would be difficult for a translator to get the word order correct for a String that is made up of multiple parts.

How are people doing this? Please help. Thanks.
 
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the API docs for java.text.MessageFormat:

"MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to construct messages displayed for end users."

Sounds exactly like your question. You could probably go a long way with that class.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I was thinking that I could have two keys in a properties file:
1) returned=Returned results for
2) returned.part.two=in:
The problem is that I know that word order can vary in different languages...


The only way to avoid this kind of problem is to not separate in two tokens the sentence. Instead you should use a message with argument(s):

returned=Returned results for {0} in:

Then it would be easy to change the word order in another locale.
You should read the documentation of java.text.MessageFormat class.

Regards
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic