How would I get the system’s current language and use that for the ResourceBundle?
Lets say the client’s machine is running in Japanese, then I want my application to switch to Japanese, if that language file is not available, it should have a fallback solution.
I know I can use the ResourceBundle, but how would I accomplish the above mentioned setting?
ResourceBundle bundle = ResourceBundle.getBundle("lang", new Locale("jp", "JP"));
The resource bundle automatically tries the system’s current language, and then falls back to the default if that doesn’t exist (
ResourceBundle.getBundle("lang")will search in the following order, presuming that the system language isjp_JP:lang_jp_JP.properties->land_jp.properties->lang.properties). You can look at the process ResourceBundle uses to resolve names here