中文 | English

RocketDriver Pro

Logo

RocketDriver Pro is a game framework for Unity engine


3. Internationalization (i18n) - Lightweight Internationalization Solution

3.1 Preparation

Understand the internationalization requirements of the project and prepare data files.

3.1.1 Clarify the types of international languages ​​that the project needs to support

Here are English[English], Chinese[Simplified], Chinese[Traditional] as examples.

3.1.2 Prepare internationalization data files

Multiple file sets are supported, here are two file sets unity, rider for example.
image
The data format is in the form of Key-Value:
image
The current test dataset is authored using Jetbrains’ [BabelEdit] (https://www.codeandweb.com/babeledit), which is a nice tool.

3.2 Initialize by registering internationalization informations

3.2.1 Register languages with the registry.

Call the RegisterLang function in the I18NRegister instance:
image

3.2.1 Loading information to the registry registration file set

Call the RegisterFile function in the I18NRegister instance:
image

3.2.3 According to the registry, load data into the manager

Call the LoadData function in the II18NManager instance:
I18NManagerShared.Manager.LoadData();
image

NOTE: If you have performed load data in the past, you should clear the old data first:
I18NManagerShared.Manager.ClearData();
image

3.3 Initialize by configuring asset

3.3.1 Generate configuration assets and configure information

  1. Select the generation directory of the configuration assets, click the menu “Tools -> RocketDriver -> Project -> Gen I18NSettings”.
  2. The generated asset file is named “I18NSettings.asset”.
  3. Set the extension name of the fileset: Asset Extension. “json” is suggested here.
  4. Add the fileset to the Assets configuration list. Or set one of them as default (only the last default takes effect).
    image

3.3.3 Initializing data by configuring assets

Call the LoadDataFromSettings function in the II18NManager instance:
I18NManagerShared.Manager.LoadDataFromSettings(settings);
image

3.4 Use

3.4.1 Use the I18NTMPText component to add internationalization support to TMP_Text.

Add I18NTMPText component to TMP_Text node
image

3.4.2 Use the I18NText component to add internationalization support to Text.

Add I18NText component to Text node
image

3.4.3 Reading internationalized data in code.

I18NManagerShared.Manager.GetValue(id, fileKey, lang); image

3.4.4 Internationalize the text content in the code.

Support script format in the file content: ``
I18NManagerShared.Manager.GetContent(content, fileKey, lang);
image

3.5 Example

JLGames/RocketDriver/Samples/i18n
image