Skip to content

Localization

yenmoc edited this page Apr 21, 2024 · 8 revisions

You can access it through the wizard window Tools > Pancake > Wizard > Localization

image

Setting

  • Avaiable Languages: List of languages supported in game localization
  • Detect Device Language: First time open app using device language to display locale
  • Import Location: Path to directory to import/export data from csv files
  • Google Translate API Key: API Keys are generated from the Credentials menu in API & Serivces on the Google Play Cloud Console

image

  • Spreasheet Key: your google sheet identifier, from your browser's address bar, you can extract your Google Sheet identifier. The format is like this:

image

  • Service Account Credential

First, visit Google API Console. Pick API & Services > Credentials from sidebar menu.

Create project if you don't have any. Then pick Create Credentials > Service Account.

image

Then please fill in all information

image

Then create successful now you can get key service account Credential by click your new service account and select Keys tab. Pick Add Key > Create New Key.

image

image

After you have downloaded this key, copy its contents and fill in the Service Account Credential field

Note that you need to enable Google Sheet API service on google cloud console

image

Now go back to your google sheet and share this sheet with the email of the service account you just created so this account has access

image

At this point, you can press the import button right next to the spreadsheet field to retrieve all the data from the google sheet and create new locale text if not available. If available, the content will be updated, including changes. like adding a new language

Explore

image

Button in bottom bar

  • Setting : select locale setting
  • Reload : reload data display in explore tree
  • Create : menu create locale asset
  • Rename : rename selected locale in tree
  • Delete : delete selected locale asset in tree
  • Import : Import locale data from csv file
  • Export : Export current locale data in project to csv file
  • Translate By : Translate current selected locale asset in tree (only languages have field empty was translated)
  • Translate All : Translate all locale asset in project
  • Fill All Localetext: Sync language for all locale text same with list AvaiableLanguage
  • AppLanguage : button change current language using in project
  • Button Plus : add language for selected locale asset
  • Button Minus : remove language in selected locale asset

Usages

Attach locale component in to object you want to localization (ex: LocaleTextComponent, LocaleFontComponent, LocaleMaterialComponent...)

image

For example, here we will localize Text curent level in the game, we will add component LocaleTextComponent which will automatically receive components and properties if the object contains Text or TextMeshProUGUI component.

We will drag the LocaleText asset into the variable or create it directly with the create button. If the text changes value like (Level 1, Level 2, level 3...) we will use format args because the text level here has only one arg so the Format Args array will only have one element. In localeText text_level we fill in the text as follows

image

Now we want to change the value of the text level somewhere else, instead of declaring TextMeshProUGUI and changing the text as before, we will declare LocaleTextComponent and use the UpdateArgs function.

[SerializeField] private LocaleTextComponent localeText;

private void OnValueChanged(int level) { localeText.UpdateArgs($"{level + 1}"); }
Clone this wiki locally