• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Localisation

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,
just a quick question obout the localisation of programs, i was looking at the java sun tutorial and came across how to handle compound messages as follows.
Java code:


Locale file:


But say if i wanted to have a new line escape character in the java code such as \r\n, how would that be handled in the locale file does anyone know?
for example

How would i represent the \r\n in the locale file as a new line escape??

Thanks
Mark
[/code]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I'm aware MessageFormatter supports escape character. Have you tried this?

I personally would shy away from using the MessageFormatter class for internalionalisation though. Sun chose to use the ' character as an escape character in properies files. Getting a non-techie (such as a translator) to properly escape things is difficult, doing it yourself is hard (unless you also speak the language in your property file). What you end up with is then need to write this:

as
My experience is this generates loads of formatting mistakes in big files. And it means you can end up needing a properties file for any code that accesses it as via a MessageFormatter, and a seperate file for any code that uses the values directly via a ResourceBundle.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can just put the \r and \n as it is in the locale files.
All strings from the locale file are considered as java strings and the place holders for {0} etc. are replaced by the runtime values.
 
Mark Hughes
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nitesh for that, just wanted to make sure because i did not see any topic in the tutorial mentioning escape characters.

And thanks Paul, so if i have to use characters such as ' i will need to place two of them in the properties back to back like '' in order to have one appear in the program after compilation. alright cool.

Thanks for the help

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic