Skip to content

Add support for Java Property Resource Bundles #1

@d4nirod

Description

@d4nirod

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 !)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions