localization - Loading of Java message properties for internalization -
i have following java i18n message class.:
public class messages { private static final string bundle_name = "languages.message"; private static final resourcebundle resource_bundle = resourcebundle.getbundle(bundle_name); private messages() { } public static string geti18n(string key) { try { return resource_bundle.getstring(key); } catch (missingresourceexception e) { return '!' + key + '!'; } } public static string geti18n(string key, object... params ) { try { return messageformat.format(resource_bundle.getstring(key), params); } catch (missingresourceexception e) { return '!' + key + '!'; } } }
i have created following message properties files.:
message.properties message_de.properties message_de_de.properties
in program translation according default locale of system. if de_de
, german message properties message_de_de.properties
loaded.
if default locale de_ch
, there no message properties file. message_de.properties
fallback loaded or need implement myself?
according this blog post right.
so when default locale of system de_de , request resource locale en_us, lookup order properties files is:
- myapp_en_us.properties
- myapp_en.properties
- myapp_de_de.properties
- myapp_de.properties
- myapp.properties
Comments
Post a Comment