Localization

The module was created to simplify the localization process for you Unity app. Which means by purchasing this asset you will also get pa owerful set of tools to work with google spreadsheets and store not only your localization but game config or any other stuff you like as well.

By storing your localization with google doc you gain advantages like:

  • Your localization is human readable comparing to keeping it in the XML, JSON files, etc.
  • You can send a link to your google doc to anybody to assist you with current localization or add new languages.
  • You can use all power of google doc formatting, like colors, fonts event formulas if you like.

Once you registered Google Spreadsheet document link, you able to read and use document data. In the localization section, you may choose the document to be a localization data provider.  Once you have done with it, the plugin will analyze the document and let you know general info, how many sections are available and how many languages were found. 

You may use "Example Settings" button. To see the example setup, and test an API.  The plugin will use the  Localization Example Shpreasheet. As the localization data source.

Using the localization API.

There a w 2 ways how you can use the localization API once the localization document has been set. After the document is parsed enum classes GD_LangSection (sheet's names in your document) GD_LangCode(your document detected languages) will be altered depending on parsed document info.

Init API

You need to init the localization API before you use it. Best place is your application launch flow:

using SA.Productivity.GoogleSheets;
...

GD_Localization.Init();

Localization API always star's with last selected langue, or if that is the first start with the first language inside the GD_LangCode  enum. You may always set language code manually in runtime:

using SA.Productivity.GoogleSheets;
...

GD_Localization.SetLanguage(GD_LangCode.en);


// If you have the components which depend on localization change,
// you can subscribed to this event
GD_Localization.OnLanguageChanged += Localization_OnLanguageChanged;
void Localization_OnLanguageChanged () {
		Debug.Log("Localization Changed: " + GD_Localization.CurrentLanguage);
}

And of course, you can always get a localized string with given token with GD_Localization class

static string GetLocalizedString(string token);
static string GetLocalizedString(string token, GD_TextType textType);
static string GetLocalizedString(string token, GD_LangSection section);
string GetLocalizedString(string token, GD_TextType textType, GD_LangSection section);
static string GetLocalizedString(string token, GD_LangSection section, params object[] args);
static string GetLocalizedString(string token, GD_LangSection section, GD_LangCode lang);

Since in most cases, you want your UI text labels localized, you can use GD_LabelLocalizer component to automatically apply localization to the Unity UI Text component. See the example below: