An object implementing the Locale interface represents a locale used for internationalisation of a plugin.

Locale objects are specific for each plugin, because their behaviour may depend on the plugin’s default locale, and string translations are per-plugin.


Call locale() on a Plugin object to obtain a Locale object for the current or specified locale.


To translate a string for the UI:

  let i = P.locale().text("template");
  let translatedString = i["Please contact the NAME(Registry)"];

The use of i for the text object is a convention to match the i() template function to translate templates.

The word ‘Registry’ is replaced using the NAME() system.


property id

The ID of this locale, eg "en".

property name

The name of this locale.

property nameInLanguage

The name of this locale, in the locale’s language.

property plugin

The Plugin which created this Locale object.

property defaultForPlugin

true if this Locale is the default locale for this plugin, false otherwise.

function text(category)

Returns a JavaScript Object for a given category which acts as a dictionary to translate text.

Text is interpolated with NAME().

For strings which are used in the user interface, always use the "template" category to match your HSVT templates.