Game.UI.Localization.LocalizationUtils
Assembly: Assembly-CSharp
Namespace: Game.UI.Localization
Type: static class
Base: System.Object
Summary:
Utility helpers for localization keys used by Cities: Skylines 2. This static class provides a small helper to combine a base locale identifier with a random localization index. The method is intended to produce keys like "LOCALE_ID:3" when an index is present, or return the original key unchanged when no index is specified.
Fields
- This static class defines no instance or static fields.
Internal behavior depends on the RandomLocalizationIndex type (from Game.Common), which contains the m_Index integer used by the helper.
Properties
- This static class exposes no properties.
Constructors
- This static class has no constructors (static classes cannot be instantiated).
No static constructor is defined.
Methods
public static string AppendIndex(string localeId, RandomLocalizationIndex randomLocalizationIndex)
Appends a numeric index to a locale identifier when the provided RandomLocalizationIndex indicates a valid index.
Behavior details: - If randomLocalizationIndex.m_Index == -1, the method returns the original localeId unchanged (interpreted as "no index"). - Otherwise it returns a new string in the format "{localeId}:{index}". - Passing a null localeId will result in a string like ":N" (where N is the index) — the method itself does not throw on a null localeId. - The method does not perform additional validation on the index; -1 is treated specially only because of the explicitly coded check.
Notes for modders: - RandomLocalizationIndex is defined in Game.Common and exposes the integer field m_Index. The semantics used here treat -1 as "no random index". - Use the returned string as a localization lookup key when selecting localized text variants.
Usage Example
using Game.Common;
using Game.UI.Localization;
public void Example()
{
string baseId = "BUILDING_NAME_SPECIAL";
// Case 1: no random index
RandomLocalizationIndex none = new RandomLocalizationIndex { m_Index = -1 };
string key1 = LocalizationUtils.AppendIndex(baseId, none);
// key1 == "BUILDING_NAME_SPECIAL"
// Case 2: with index
RandomLocalizationIndex idx = new RandomLocalizationIndex { m_Index = 2 };
string key2 = LocalizationUtils.AppendIndex(baseId, idx);
// key2 == "BUILDING_NAME_SPECIAL:2"
// Use the resulting key with your localization lookup system:
// string display = LocalizationManager.Get(key2);
}