0

I am planning to make a website written in JSP/Java available in multiple languages, now I wonder how I would do that in a nice manner, currently I got one proposal as approach, but I also wonder if something else is possible.

The proposal: Have a class Language.java responsible for managing the language, preferably the data itself should be stored in for example .txt files, atleast some simple format that others (possibly non-programming related) can also work with.

Very basic setup:

english.lang:

RegisterUsername => Username
RegisterPassword => Password
RegisterPasswordConfirmed => Confirm password

Calling code:

Language language = new Language(); 
//constructor of Language should determine what language to use
System.out.println(Language.get("RegisterUsername"));
//would show the string in the respective language

Second thought: Some code like ${RegisterUserName} would even be more handy, but I'm afraid that this is not possible.

How should I implement the internatiolization?

Regards.

skiwi
  • 66,971
  • 31
  • 131
  • 216
  • Thanks a lot BalusC, somehow though the question is not a duplicate (in my opinion), but that answer is definately one I am looking for. – skiwi Jun 27 '13 at 14:21
  • Sorry I have been to quick, I am unable to use what you have suggested in the other thread in pure Java, how would I do so? – skiwi Jun 27 '13 at 14:37
  • Just use `java.util.ResourceBundle` API, as JSTL is also using under covers. Note: it's absolutely not recommended to write down Java code in JSP. I assume that you actually mean a servlet class when you said "pure Java". – BalusC Jun 27 '13 at 14:47
  • Indeed I meant a server class, and I'll take a look at the ResourceBundles then. – skiwi Jun 27 '13 at 15:14

0 Answers0