-
-
Notifications
You must be signed in to change notification settings - Fork 8
[EU] Localisation
In order to distribute games to a wider audience you might need to translate text to different languages. The localisation API provides a way to easily translate your text to different languages.
Before we begin you need to create a new folder under Config/
, called Translations
. Inside of it you need to create a file called translation-base.yaml
. This file will act like a layout for your other translations. Example:
origin-locale: "en-US"
strings:
- "The quick brown fox jumps over the lazy dog"
- "Hello, World!"
The origin-locale
field specifies the initial and default locales. These locales are formatted in the standard lang_COUNTRY
code. A full list of the available locales can be seen here
The strings
field is a sequence of strings in the origin locale. These strings will then be used as identifiers for translating.
To create a translation create a new file with its name bein one of the languages in our list of supported locales e.g. bg_BG.yaml
and fill it with data like this:
strings:
- string: "The quick brown fox jumps over the lazy dog"
translation: "Бързата кафява лисица прескача над мързеливото куче"
- string: "Hello, World!"
translation: "Здравей свят!"
Here we have translated our original English text to Bulgarian. The strings
tag is a list of objects, each of these objects is of type string
, which in its parent data contains the original en_US
text, while under the translation child it holds the Bulgarian text.
These files are automatically indexed so adding a new translation is as easy as adding a new file with a new locale name
The Locale
interface contains a bunch of functions to interact with the localization system.
- The
getLocaleName
function returns a string containing the short or long name of the provided locale. You can enable short text by setting the last parameter to true and vice-versa - The
getLocaleID
function takes a string formatted in the short locale form and returns the given locale - The
getLocaleString
function takes a string and a locale argument. On call it fetches the translation of the string for the specified locale and returns it if valid - The
getCurrentLayout
andgetFallbackLayout
functions are self explanatory
This project is supported by all the people who joined our discord server and became beta testers. If you want to join the discord you can click here
- Home
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources