Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The NautDrafter project has the ability to use

...

a user-selected language for the text in its interface. This is achieved via Java Resource Bundles, which make it easy for users to add their own translations to the app, without having to touch a line of code.

Note

We have a FOSS license for POEditor. Update docs to reflect translation work. To sign up use this link: https://poeditor.com/join/project?hash=36c5fa33d952955c6c0afea7b9e780ef

 

Resource Files

The resource files that contain the string for the NautDrafter user interface can be found in nautdrafter.bundles.  These files are named in the format Strings_[ISO 639 alpha-2 or alpha-3 language code]_[ISO 3166 alpha-2 country code].properties. For example; Strings_en_GB.properties.

Current Files

...

...

...

...

...

...

...

...

...

...

...

...

on the login screen and be able to be selected.

It should be noted that if a particular string is missing from the bundle, then it will automatically fall back to the default Strings.properties which is in English (UK). As an example, for en_US only strings that are spelt differently (e.g. color or mom) need to be defined and the rest will fall back to the common English spelling.

Using Localized Strings from Java Code

From anywhere in the main NautDrafter Java code, calling NautDrafter.getBundle() will give you the appropriate ResourceBundle that should be used whenever you are setting a string that is displayed in the user interface. For example, rather than:

this.textInput.setPromptText("Enter chat message"); // Bad!

use:

this.textInput.setPromptText(NautDrafter.getBundle().getString("chat.prompt")); // Good!

Additionally, if you're loading an FXML file, it is important to pass in the bundle so that the any internationalized strings in the FXML will be displayed in the correct language. For example:

FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("/com/monkygames/nautdrafter/view/TeamSelectionScreen.fxml"), NautDrafter.getBundle());