Skip to content
Advertisement

How to specify, which resource file to be used while running?

I wants my application to be in both Hindi and English language, so I have created a ResourceBundle named as Resources. In this directory I have create label.properties,label_en_US.properties and label_hi_IN.properties and these file have putted some values like ab=xy_default, ab=xy_in_en and ab=xy_in_hindi respectively.
enter image description here

And Now I planned to use them as label text, so in property of that label i mantioned the default one, like thisenter image description here
Here code is key and In label_defualt is code=Code : , in label_en_US code=Code : and in label_hi_IN code=कोड :. How can I specify which of label.properties to be useout of label, label_en_US or label_hi_in. I have stored user preference in my database like which language to use.
I want to know how I can force or tell it use that particular file out of label, label_en_US, label_hi_IN in main function or somewhere else.
As now it’s taking values from label.properties file only, if user want it to be in hindi then how internally we force to use that label_hi_IN.properties file.

Advertisement

Answer

Finally I got it, We have to just set Default Locale.

Locale locale = new Locale("hi","IN");
Locale.setDefault(locale);
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement