I was trying to understand the Internationalization . So I have written the following two properties file and and the Java class .
They are working fine when I am invoking the Java class with command line argument also (Passing the argument for local) for example % java I18NSample en US Hello. How are you? Goodbye.
Please clear my confusion .What I understand when I will run this program from US it should output US version properties file and If I run it from a German machine it should fetch the German value .
My program is able to fetch the correct data only after I pass the Local values as a parameter in main() .So is it the programmer's responsibility to identify from which country the client is asking data and depending that we will call the correct version of properties file ?
If the answer is yes then how do I know who is calling my server what is the local for this client ?
Please see the code below from sun :
greetings = Hello. farewell = Goodbye. inquiry = How are you?
greetings = Hallo. farewell = Tsch��. inquiry = Wie geht's?
According to the javadoc (I haven't tried it), if you don't specify a Locale, the getBundle method used the default i.e.should do what you want
Joined: Oct 10, 2007
Thanks for all your reply .
But I am not able to get what I am exactly want .May I not communicated clearly to understand what I want .
I want a way if it is there in I18N so that my program will automatically fetch the correct properties value . I mean I will write a program and deploy it in server now if Germany comes as a client it will pick the German properties file if US come it will pick the English one .
As you mentioned if I use the default that will be Say language English So fetching default will not provide the German client the German properties file .It it will pick up default and show a German client a English one .
I mean I am asking.... should my application know the local ,means is that mandatory to pass the local value through URL or something ?So that knowing that value it will fetch the correct properties file ?
To be very clear when I hit the google from india I get the english one but when a chinies open the google.com he opens the chinies page so How thease works ?
Joined: Feb 29, 2008
Yes, in this case, you must send to the server the locale of the client. In Google's case, the Locale is sent by the browser in the header of the request. You can use the same approach (if it's a web app).
Make this experiment: Try change you language configuration in your browser (e.g. on IE7*, Tools/Internet Options, click on button Languages). Add a new language on the top of the list and access Google site.
* Sorry I don't have Firefox installed here, but you can do the same on it