Localization - Ellpeck/TinyLifeExampleMod Wiki

Tiny Life

TinyLife

Localization Class

A class that houses the currently loaded language as well as allows for switching the currently selected language

public static class Localization

Inheritance System.Object 🡒 Localization

Fields

Localization.LanguageNames Field

A list of the full names of all of the languages that the game supports

public static readonly Dictionary<string,string> LanguageNames;

Field Value

System.Collections.Generic.Dictionary<System.String,System.String>

Localization.Names Field

A dictionary that maps a key to all of the names matching the specified key.
By default, this dictionary contains "FirstNames" and "LastNames", which are the randomly generated names for people.

public static readonly Dictionary<string,string[]> Names;

Field Value

System.Collections.Generic.Dictionary<System.String,System.String[]>

Methods

Localization.Get(LnCategory, string, object[]) Method

Gets a localized string in the given category with the given key.
If the localization is not found, the key, surrounded by question marks, is returned instead.

public static string Get(TinyLife.LnCategory category, string key, params object[] args);

Parameters

category LnCategory
The category that contains the localization

key System.String
The key to localize

args System.Object[]
An optional set of arguments that are passed to System.String.Format(System.IFormatProvider,System.String,System.Object)

Returns

System.String
The localization of the key

Localization.Get(LnCategory, string) Method

Gets a localized string in the given category with the given key.
If the localization is not found, the key, surrounded by question marks, is returned instead.

public static string Get(TinyLife.LnCategory category, string key);

Parameters

category LnCategory
The category that contains the localization

key System.String
The key to localize

Returns

System.String
The localization of the key

Localization.GetKeys(LnCategory) Method

Returns all of the keys that are registered for localization for a given LnCategory

public static System.Collections.Generic.IEnumerable<string> GetKeys(TinyLife.LnCategory category);

Parameters

category LnCategory
The localization category

Returns

System.Collections.Generic.IEnumerable<System.String>
A set of keys

Localization.SetLanguage(string) Method

Switches the current language to the language given.
Note that, for most ui elements to update, they have to be re-created.

public static void SetLanguage(string language);

Parameters

language System.String
The code of the language to set