Translate extension

This extension allows you to easily manage translations of your game within external JSON files, separating translation functionality from your game logic with pre-built functions and behaviors.

Features

  • Load language based on the player’s preferred system/browser language, and also fall back to default language if no translations exist for any of user’s preferred languages.
  • Supports different locales for the same language, for example you can have different translations for US English (en-US) and British English (en-GB) and even a default fallback (en) for any other variant of English which you don’t directly support.
  • Translations are loaded in a global variable, so they are available in all of your scenes.
  • Support for parameters in translations - insert dynamic strings (variable values) in your translations.

Demo video

Translation files

Translation files should be stored in your project folder root as [locale].json (de-DE.json) or [language].json (de.json). Example:

{
   "Choose your language:": "Wählen Sie Ihre Sprache:",
   "My name is {1}, {0} {1}.": "Mein Name ist {1}, {0} {1}.",
   "Chosen: {0}": "Ausgewählt: {0}",
   "English": "Englisch",
   "Serbian": "Serbisch",
   "German": "Deutsch",
   "French": "Französisch",
   "Italian": "Italienisch",
   "Chinese": "Chinesisch",
   "Russian": "Russisch",
   "Greek": "Griechisch",
   "Play": "Spielen",
   "Go back": "Zurück"
}

:warning: Your translation files must be loaded to your game Resources as well in order for them to be exported with your game when you export a game build.

Parameters (advanced)

This extension supports parameters in translations, which means you can have a key (default text) like this: Hello {0}!. Then if you call Translate::translate("Hello {0}!", PlayerAuthentication::Username()) it will translate the string and replace {0} in the resulting (translated) text with authenticated user’s user name. So if the player is logged in as “John Wick”, in English it will show as “Hello John Wick!”, but in your German translation you can have “Hallo {0}!” so it will show as “Hallo John Wick!”.

Online demo and download

3 Likes