• 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

Internationalisation of messages with Apache Commons Logging

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone point me at an example of how to do internationalization using Apache Commons Logging and Log4J.

The messages I need to log will also need to output the values of a local variable
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dar Var

One way you could do it is to pass property values into your log, that way all you need to worry about is keeping your internationalized versions of the properties files up to date...
See here for more info
 
Dar Var
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand the Java localization stuff. But how to use it with Apache Commons Logging:



If I get the log messages using a ResourceBundle, is there any way to pass this into Apache Commons Logging.

Do I need to implement the Log Interface to get the info, debug etc methods to use a ResourceBundle.
 
James Dixon
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be pretty much there. All you should have to do is pass in the localized string when listing your log value e.g.:
As a word of advise, if you do go down this route, I would suggest that you override resourceBundle.getString, to pass back a default value if the locale cannot be found.

Other than that have fun!
reply
    Bookmark Topic Watch Topic
  • New Topic