Property Resource Bundles
Standard Java localisation is based on property resource bundles by way of properties files with roughly this scheme:
- Base/default strings file, e.g.
messages.properties
- localised child/dependant files with added
_xx ISO language code suffix:
messages_es.properties
messages_ru.properties
messages_de.properties
So when you tell Java to get a string localised to German whose key is task.done. you use a ResourceBundle and only need to provide the base or bundle name, i.e. messages and the locale:
ResourceBundle rb = ResourceBundle.getBundle("messages", Locale.GERMAN);
String taskDoneMsg = rb.getString("task.done");
Properties file format
The format we use in our properties files is one key-value pair per line using the equals sign = as separator like so:
string_key_name = String value
For example
task.done = {0} <strong>set this Task as done</strong>
See https://github.com/fwHub/cw-server/tree/development/cw-server/src/main/resources
Encoding is ISO-8859-1 as per standard with Unicode-encoded (\uddd notation) characters.
so we use the string organizaci\u00f3n instead of organización
The format supports other rules like : separator instead of = but we don't use them, still, I strongly recommend reading it (it's short) to understand the handling of whitespace and comment lines (# or !)
Property Resource Bundles
Standard Java localisation is based on property resource bundles by way of properties files with roughly this scheme:
messages.properties_xxISO language code suffix:messages_es.propertiesmessages_ru.propertiesmessages_de.propertiesSo when you tell Java to get a string localised to German whose key is
task.done.you use aResourceBundleand only need to provide the base or bundle name, i.e.messagesand the locale:Properties file format
The format we use in our properties files is one key-value pair per line using the equals sign
=as separator like so:string_key_name = String valueFor example
task.done = {0} <strong>set this Task as done</strong>See https://github.com/fwHub/cw-server/tree/development/cw-server/src/main/resources
Encoding is
ISO-8859-1as per standard with Unicode-encoded (\udddnotation) characters.so we use the string
organizaci\u00f3ninstead oforganizaciónThe format supports other rules like
:separator instead of=but we don't use them, still, I strongly recommend reading it (it's short) to understand the handling of whitespace and comment lines (#or!)