Skip to content
TheE edited this page Jan 7, 2020 · 7 revisions

MyWarp is fully localised. All messages can be translated - or altered in other ways, like rewriting them to fit your server's theme (think of RPGs...) more closely.

MyWarp bundles multiple user-contributed localisations. While localisations can be added manually, it is recommended to contribute to the official localization project on crowdin. This way, everybody can use the new or updated translations.

Configuration

Localizations can be configured in the configuration file:

Configuration Node Effect
localization.defaultLocale  The locale to be used as default, e.g. when displaying messages in the console.
localization.perPlayer  Controls whether players will receive localized messages using their client's locale. If set to false, messages will have the default locale.

Note: The syntax for the locale follows the Java standard as described here: The first part represents the language, the last part represents the country.

Using Custom Localisations

MyWarp bundles several user-contributed localizations. If you want to translate MyWarp into your language or correct a mistake in an existing translation, please contribute the change at the official crowdin project. New translations are always greatly appreciated, too.

Adding a Custom Translation

To add new custom translations, create a set of nested folders inside of MyWarp's plugin folder so that the following path exists: mywarp-plugin-folder/lang/io/github/mywarp/mywarp/lang/. New translations can be added to the innermost lang folder.

Translations are correctly named properties files, encoded in UTF-8. To get started, simply copy the English files bundled by MyWarp and translate their content. To do so, copy all files ending with _en from here and here into the inner lang folder. Translate the content (using placeholders as described below), then replace the _en with the actual locale of your files. For example, if the Commands_en.properties are translated to Italian, it needs to be renamed to Commands_it.properties.

If your locale is country-specific (e.g. you have separated translations for Italian as spoke in Italy and Italian as spoke in Swiss), you can also include the country within the locale (e.g. _it_IT for Italian Italian, and _it_CH for Swiss Italian). It is recommended to move all translations common for both countries to a parent file that simply uses the language's locale (e.g. _it). Child bundles will resolve missing translations from the parent bundle.

Note: Translations can also be created online using the official crowdin project. The editor is much simpler to use than the process described above and handles naming conventions and variables automatically.

Overwriting Bundled Translations

Translations bundled with MyWarp can be overwritten. To do so, create the nested folder structure as described above, and copy the file you wish to overwrite into the innermost lang folder. Make the changes but do not change the file name.

After a restarting the server or reloading MyWarp, the new file is used instead of the old one.

Note: MyWarp bundles default translations that are used if no translations for a certain locale exists. These files are equivalent to the English versions but do not have a locale suffix. They cannot be overwritten.

Understanding variables

Several messages contain placeholders that are dynamically filled with content. Placeholders are enclosed in braces.

Note: Java escapes braces by enclosing them in quotes. If you want to output a replaced placeholder enclosed with quotes, you need to enclose it with four quotes, e.g. ''{0}'' becomes 'my-variable'.

A full explanation of this behaviour, which is provided by Java's MessageFormat, is beyond the scope of this article. Instead, you can find a quick explanation below.

String Placeholders

A normal placeholder is replaced by a string. It consists of a number enclosed by braces. If a message uses multiple placeholders for different strings, they have different numbers.

Example:

  • You have uninvited {0} from ''{1}''.

Number Placeholders

A number placeholder is replaced by a number. To correctly format the number, the placeholder includes information over the type of number (integer, decimal etc.). For decimals, hashes control how many numbers are displayed after the comma.

Examples:

  • Integer value: Warp names can only contain {0, number, integer} characters.
  • Decimal value (rounded to three numbers after the comma): ({0,number,#.###} visits per day)

Choice Placeholders

A choice placeholder is used when the grammar of the sentence needs to change based on a number (e.g. singular instead of plural). The placeholder can be read as a definition of what text to use for what number or range of numbers.

Example:

  • If the number is 1, only one page is displayed. If it is larger than 1, the text with the number is displayed: There {0,choice,1#is only one page|1<are only {0, number, integer} pages} in total.

Welcome Messages

Welcome messages have a special set of variables that can be used in the default welcome message (defined in the corresponding translation). These variables can also be used in-game when changing a warp's welcome message.

variable description
%loc% The location of the warp (e.g. (20, 64, -512)).
%player% The name of the player who visits the warp.
%visits% The current number of visits.
%warp% The name of the warp.