Class Localization
- Namespace
- TinyLife
- Assembly
- Tiny Life.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
category
LnCategoryThe category that contains the localization
key
stringThe 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
category
LnCategoryThe category that contains the localization
key
stringThe key to localize
args
object[]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 continent 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 continent. Returned entries for last names are arrays with two entries: the name and the most common continent.
public static IEnumerable<string[]> GetAllNames(bool lastName, StylePreference preference = StylePreference.Neutral)
Parameters
lastName
boolWhether to return last names, rather than first names.
preference
StylePreferenceThe 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 continent. Returned entries for last names are arrays with two entries: the name and the most common continent.
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
category
LnCategoryThe category that contains the localization.
key
stringThe 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
category
LnCategoryThe 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 continent 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
random
RandomThe Random instance to use for the random choice.
lastName
boolWhether to return last names, rather than first names.
preference
StylePreferenceThe 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
language
stringThe code of the language to set