TranslationServer
Manages the game locale and message lookup in registered translations.
Selects messages from registered Translation resources using the current and fallback locales. Translate returns the source key when no translation is found; key and context must match. TranslatePlural selects a plural form but does not format placeholders.
SetLocale changes the active locale and sends a translation-change notification. Recalculate custom computed text in the notification handler. The method does not persist the player preference. Loading a resource without AddTranslation or project registration does not include it in lookup.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties2
PseudolocalizationEnabledProperty
public static bool PseudolocalizationEnabled { get; set; }Main-domain automatic pseudolocalization state rather than named-domain state. The setter reloads remap resources and sends a translation-change notification even for the same value. Currently transforms Translate but not TranslatePlural. Explicit Pseudolocalize works independently of the flag.
SingletonProperty
public static TranslationServerInstance Singleton { get; }Borrowed engine-service instance shared by the static API. Normally use static TranslationServer calls. Do not create a replacement or call Free/Dispose on this instance.
Methods35
AddTranslationvoid
public static void AddTranslation(Translation translation);Adds a shared Translation resource to the main domain. Re-adding the same object is idempotent; another object of the same locale is allowed but equal-score priority is unspecified. Sends no notification to refresh existing UI text and adds nothing to named domains.
| Name | Type | Default |
|---|---|---|
translation | Translation | — |
translationNon-null shared Translation resource; registration/removal compares the object rather than just Locale.
Clearvoid
public static void Clear();Clears only the main domain catalog set. Resets neither active locale, pseudolocalization settings nor named domains, and clears no Translation resource contents. A project-global action: remove only your own addon resources/domain for local cleanup.
CompareLocalesint
public static int CompareLocales(string localeA, string localeB);Compares locales: 10 for an exact or normalized equivalent match, a positive score for the same language, and 0 for different languages. This is similarity, not a check that a translation exists.
| Name | Type | Default |
|---|---|---|
localeA | string | — |
localeB | string | — |
localeAFirst locale in canonical form, for example ru_RU.
localeBSecond locale to compare, for example ru.
intScore from 0 to 10; a positive score does not establish resource availability or satisfy every script requirement.
FindTranslationsReckfell.Collections.Array<Translation>
public static Reckfell.Collections.Array<Translation> FindTranslations(string locale, bool exact);Returns a separate Array<Translation> container of matching main-domain catalogs. exact=true compares Locale literally without normalization; false selects all CompareLocales>0 matches. Does not sort by specificity, test for a message or include named domains. Elements are shared resources.
| Name | Type | Default |
|---|---|---|
locale | string | — |
exact | bool | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
exacttrue for literal Locale comparison; false for all positive CompareLocales matches.
Reckfell.Collections.Array<Translation>New container of all matching shared main-domain catalogs without an order guarantee.
FormatNumberstring
public static string FormatNumber(string number, string locale);Transforms numeric-string characters for the locale numbering system. Looks up locale literally; standardize it first. For supported systems replaces digits, e/E and both period/comma with the separator. Does not format a numeric value, group digits, validate text or apply C# culture formatting. An unmapped numbering system passes input through. For ar, 12.5 becomes ١٢٫٥.
| Name | Type | Default |
|---|---|---|
number | string | — |
locale | string | — |
numberText rather than a numeric object. The method replaces characters without numeric validation; validate the result separately.
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
stringCharacter-transformed text or original input for an unmapped key.
GetAllCountriesstring[]
public static string[] GetAllCountries();Returns a new string[] of built-in country/region codes rather than the current country of the user. Order is unspecified; obtain labels with GetCountryName.
string[]New identifier array without a sorted-order guarantee; edits no underlying table.
GetAllLanguagesstring[]
public static string[] GetAllLanguages();Returns a new string[] of codes from the built-in language table. Independent of loaded catalogs, without sorted-order or project-translation-coverage guarantees. Map codes through GetLanguageName and sort separately for UI.
string[]New identifier array without a sorted-order guarantee; edits no underlying table.
GetAllScriptsstring[]
public static string[] GetAllScripts();Returns a new string[] of built-in writing-system codes such as Latn. Neither programming languages nor installed font coverage; order is unspecified.
string[]New identifier array without a sorted-order guarantee; edits no underlying table.
GetCountryNamestring
public static string GetCountryName(string country);Finds a country/region label by exact table code such as US. Unknown codes pass through; performs no automatic case normalization or active-locale translation of labels.
| Name | Type | Default |
|---|---|---|
country | string | — |
countryExact built-in table code; unknown input passes through.
stringTable label or original unknown code.
GetLanguageNamestring
public static string GetLanguageName(string language);Finds a language name by exact table code such as en. Unknown codes pass through unchanged. Names come from a built-in table and are not automatically translated by SetLocale; do not pass full ru_RU where ru is required.
| Name | Type | Default |
|---|---|---|
language | string | — |
languageExact built-in table code; unknown input passes through.
stringTable label or original unknown code.
GetLoadedLocalesstring[]
public static string[] GetLoadedLocales();Returns the locales of resources registered in the main translation domain. Does not list every engine-known language or verify that every message is translated.
string[]Array of registered locales, which can be empty. Use GetAllLanguages for the catalog of known language codes.
GetLocalestring
public static string GetLocale();Reads the active server locale. Not necessarily the original OS locale, a loaded-language list or an individual Translation Locale/domain override.
stringActive server locale identifier.
GetLocaleNamestring
public static string GetLocaleName(string locale);Standardizes locale and composes a display name from built-in language, script and country labels when present. A human-readable label rather than a stable identifier or automatically localized UI text.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
stringComposed built-in display label rather than a locale key.
GetOrAddDomainTranslationDomain
public static TranslationDomain GetOrAddDomain(StringName domain);Returns an existing named domain or creates an empty one. Use a unique addon name, such as its addons path; multiple owners must coordinate removal.
| Name | Type | Default |
|---|---|---|
domain | StringName | — |
domainDomain name. An empty name selects the main project domain, not a new private domain.
TranslationDomainTranslationDomain for the name. Retrieval alone neither loads dictionaries nor assigns the domain to a Control.
GetPercentSignstring
public static string GetPercentSign(string locale);Returns a numbering-system percent sign by exact nonempty locale key, or % when unmapped. Does not multiply a value by 100, format a number or choose sign placement.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
stringNumbering-system sign or %, without a number.
GetPluralRulesstring
public static string GetPluralRules(string locale);Looks up rule text by exact table key then parsed language+country and language. Returns empty text on a miss; the English fallback is selected by Translation rather than this method. Validates no catalog form count and inserts no count into text.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
stringGettext rule text or empty text when unavailable.
GetScriptNamestring
public static string GetScriptName(string script);Finds a writing-system name by exact code such as Latn. Unknown values pass through. Neither a C# script name nor a font-support check.
| Name | Type | Default |
|---|---|---|
script | string | — |
scriptExact built-in table code; unknown input passes through.
stringTable label or original unknown code.
GetToolLocalestring
public static string GetToolLocale();In editor/project-manager mode of a TOOLS_ENABLED build uses an exact editor-catalog locale match or en. In normal runtime selects a matching main-domain locale or the server fallback. Not a universal way to read editor UI language from any game; editor behavior was source-reviewed only.
stringSelected tool/runtime locale or fallback, depending on process mode.
GetTranslationObjectTranslation · Deprecated
public static Translation GetTranslationObject(string locale);Obsolete SDK method returning one best-matching shared main-domain resource or null. Guarantees neither equal-score selection nor the desired message being present. Use FindTranslations with explicit exact for lists and Translate/TranslatePlural for text.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
TranslationOne shared resource or null; obsolete API.
GetTranslationsReckfell.Collections.Array<Translation>
public static Reckfell.Collections.Array<Translation> GetTranslations();Returns a separate Array<Translation> of all main-domain catalogs without an order guarantee. Container edits change no registration; element edits change the shared resource. Do not dispose elements as newly created resources.
Reckfell.Collections.Array<Translation>New container of shared main-domain catalogs.
HasDomainbool
public static bool HasDomain(StringName domain);Checks domain registration, not availability of a particular language or translated key. The checked private domain disappeared after plugin disablement.
| Name | Type | Default |
|---|---|---|
domain | StringName | — |
domainDomain name to inspect; the empty-name main domain always exists.
booltrue for an existing domain. Does not establish that the required dictionary was loaded.
HasTranslationbool
public static bool HasTranslation(Translation translation);Tests registration of the same Translation object in the main domain. Matching Locale or contents is insufficient; the catalog can be empty.
| Name | Type | Default |
|---|---|---|
translation | Translation | — |
translationNon-null shared Translation resource; registration/removal compares the object rather than just Locale.
booltrue when that object is registered in the main domain.
HasTranslationForLocalebool
public static bool HasTranslationForLocale(string locale, bool exact);Tests main-domain catalog locales: exact=true uses literal equality and false CompareLocales>0. Checks no specific key, fallback or named domain.
| Name | Type | Default |
|---|---|---|
locale | string | — |
exact | bool | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
exacttrue for literal Locale comparison; false for all positive CompareLocales matches.
booltrue for a matching locale regardless of desired-message availability.
IsPseudolocalizationEnabledbool
public static bool IsPseudolocalizationEnabled();Reads the main-domain automatic-transformation flag. Checks neither all named domains nor visually refreshed UI.
boolCurrent main-domain state rather than a UI-check result.
ParseNumberstring
public static string ParseNumber(string number, string locale);Converts known numbering-system digits, separator and exponent back to an ASCII-digit string. Returns no numeric value and performs no syntax validation: multiple separators can remain. An unmapped locale key passes input through. Does not guarantee exact FormatNumber reversal: exponent case and original comma can be lost.
| Name | Type | Default |
|---|---|---|
number | string | — |
locale | string | — |
numberText rather than a numeric object. The method replaces characters without numeric validation; validate the result separately.
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
stringText rather than double/decimal or evidence of numeric validity.
PseudolocalizeStringName
public static StringName Pseudolocalize(StringName message);Explicitly transforms the supplied string using pseudolocalization settings for the main domain. Works even when PseudolocalizationEnabled is false. Does not look up a translation; placeholder skipping does not recognize C# composite format {0}.
| Name | Type | Default |
|---|---|---|
message | StringName | — |
messageText to transform; look up the translation first if needed.
StringNameTransformed text with configured wrappers and padding; empty input remains empty.
ReloadPseudolocalizationvoid
public static void ReloadPseudolocalization();Reloads transformation parameters from internationalization/pseudolocalization/ for the main domain and sends a translation-change notification. Does not toggle the active state from use_pseudolocalization: set PseudolocalizationEnabled separately. Does not save ProjectSettings to disk.
RemoveDomainvoid
public static void RemoveDomain(StringName domain);Removes a named domain from the registry. Remove its UI first and act only as the domain owner. Existing references can remain alive; GetOrAddDomain can create a new registration afterward.
| Name | Type | Default |
|---|---|---|
domain | StringName | — |
domainNonempty owned-domain name. Removing the main domain is rejected.
RemoveTranslationvoid
public static void RemoveTranslation(Translation translation);Removes the specific object from the main domain rather than all catalogs of that locale. Repeated removal is a no-op. Changes no membership in other domains and sends no translation-change notification.
| Name | Type | Default |
|---|---|---|
translation | Translation | — |
translationNon-null shared Translation resource; registration/removal compares the object rather than just Locale.
SetLocalevoid
public static void SetLocale(string locale);Sets a nonempty active locale with normalization. When the normalized value changes, initiates translation-remap resource reload and sends MainLoop.NotificationTranslationChanged to the main loop. Repeating the same value is a no-op. Loads no arbitrary catalogs and persists no player preference. Recalculate custom computed text in the notification handler.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier such as ru_RU. SetLocale and numeric methods require nonempty input; exact searches and numeric methods do not automatically normalize it.
SetPseudolocalizationEnabledvoid
public static void SetPseudolocalizationEnabled(bool enabled);Sets main-domain PseudolocalizationEnabled and initiates remap reload plus main-loop notification. Even the same bool sends a notification. Saves no ProjectSettings and enables no TranslatePlural transformation.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledNew main-domain bool; repeating the value also triggers notification.
StandardizeLocale2 overloads
public static string StandardizeLocale(string locale);Normalizes a locale identifier, for example ru-RU to ru_RU. It does not validate catalog availability or universally repair casing and malformed input. This overload does not add default components.
| Name | Type | Default |
|---|---|---|
locale | string | — |
localeLocale identifier with canonical casing; separators such as the hyphen in ru-RU are supported.
stringNormalized identifier. The result does not certify a translation exists or that arbitrary original input was valid.
public static string StandardizeLocale(string locale, bool addDefaults = false);Normalizes a locale identifier, for example ru-RU to ru_RU. It does not validate catalog availability or universally repair casing and malformed input. With addDefaults=true, it may add a script or country for certain ambiguous locales.
| Name | Type | Default |
|---|---|---|
locale | string | — |
addDefaults | bool | false |
localeLocale identifier with canonical casing; separators such as the hyphen in ru-RU are supported.
addDefaultsAllow known defaults for an ambiguous locale: for example zh becomes zh_Hans_CN. Does not select a language shipped by the game.
stringNormalized identifier. The result does not certify a translation exists or that arbitrary original input was valid.
TranslateStringName
public static StringName Translate(StringName message, StringName context = null);Performs main-domain lookup using active and fallback locales. Empty values count as misses; returns the source key when needed and applies enabled pseudolocalization. Does not search all named domains.
| Name | Type | Default |
|---|---|---|
message | StringName | — |
context | StringName | null |
messageSource lookup key; for Pseudolocalize, selected text to transform.
contextExact message context; null/default means empty.
StringNameFound text or source key with applicable pseudolocalization.
TranslatePluralStringName
public static StringName TranslatePlural(StringName message, StringName pluralMessage, int n, StringName context = null);Looks up a main-domain form using active then fallback locale; the chosen Translation supplies rules. On a miss returns message only at n==1, otherwise pluralMessage. Inserts no count and in SDK 1.0.0 applies no automatic pseudolocalization; explicitly Pseudolocalize the result when needed.
| Name | Type | Default |
|---|---|---|
message | StringName | — |
pluralMessage | StringName | — |
n | int | — |
context | StringName | null |
messageSource lookup key; for Pseudolocalize, selected text to transform.
pluralMessagePlural source form for fallback; not a separate Translation map key.
nNonnegative count for Translation rules; fallback uses singular only at 1. Not inserted into the result.
contextExact message context; null/default means empty.
StringNameFound form or source singular/plural without automatic pseudolocalization.