Class Localization
- Namespace
- TinyLife
- Assembly
- TinyLife.dll
A class that houses the currently loaded language as well as allows for switching the currently selected language
public static class Localization
- Inheritance
-
Localization
- Inherited Members
Fields
LanguageNames
A list of the full names of all of the languages that the game supports
public static readonly Dictionary<string, string> LanguageNames
Field Value
Names
A dictionary that contains pre-defined names, used by all languages, for Tinies as well as other named objects, usually related to a Project.
public static readonly Dictionary<NameCategory, List<string>> Names
Field Value
Methods
Get(LnCategory, string)
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(LnCategory category, string key)
Parameters
categoryLnCategoryThe category that contains the localization
keystringThe key to localize
Returns
- string
The localization of the key
Get(LnCategory, string, params object[])
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(LnCategory category, string key, params object[] args)
Parameters
categoryLnCategoryThe category that contains the localization
keystringThe key to localize
argsobject[]An optional set of arguments that are passed to Format(IFormatProvider, string, object)
Returns
- string
The localization of the key
GetAllNames(bool, StylePreference)
Returns all of the names that are meant for Tinies in the current localization, optionally taking into account the given StylePreference. To retrieve a random name while taking into account the name generation country priority of the current localization, use GetRandomName(Random, bool, StylePreference). Returned entries for first names are arrays with three entries: the name, the style preference, and the most common country code. Returned entries for last names are arrays with two entries: the name and the most common country code.
public static IEnumerable<string[]> GetAllNames(bool lastName, StylePreference preference = StylePreference.Neutral)
Parameters
lastNameboolWhether to return last names, rather than first names.
preferenceStylePreferenceThe style preference for which names should be returned. If this is Neutral, names that match any style preference are returned.
Returns
- IEnumerable<string[]>
All names that match the given
preference. Returned entries for first names are arrays with three entries: the name, the style preference, and the most common country code. Returned entries for last names are arrays with two entries: the name and the most common country code.
GetBool(LnCategory, string)
Gets a localized string in the given category with the given key and tries to parse it as a bool using TryParse(string, out bool). If the localization is not found or cannot be parsed, false is returned.
public static bool GetBool(LnCategory category, string key)
Parameters
categoryLnCategoryThe category that contains the localization.
keystringThe key to localize.
Returns
GetKeys(LnCategory)
Returns all of the keys that are registered for localization for a given LnCategory
public static IEnumerable<string> GetKeys(LnCategory category)
Parameters
categoryLnCategoryThe localization category
Returns
- IEnumerable<string>
A set of keys
GetRandomName(Random, bool, StylePreference)
Returns a random name chosen from all of the names that are meant for Tinies in the current localization, optionally taking into account the given StylePreference. This method uses GetAllNames(bool, StylePreference) to retrieve the names and then chooses one randomly. The name generation country priority of the current localization is taken into account when choosing the name.
public static string GetRandomName(Random random, bool lastName, StylePreference preference = StylePreference.Neutral)
Parameters
randomRandomThe Random instance to use for the random choice.
lastNameboolWhether to return last names, rather than first names.
preferenceStylePreferenceThe style preference for which names should be returned. If this is Neutral, names that match any style preference are returned.
Returns
- string
The random name chosen.
Reload()
Reloads the strings for the current language (SetLanguage(string)) for the base game and all mods. Note that, for most ui elements to update, they have to be re-created.
public static void Reload()
SetLanguage(string)
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
languagestringThe code of the language to set