Table of Contents

Class PoLocalizer

Namespace
Icy.Localization
Assembly
IcyUI.dll

Localized strings from gettext .po files, one per language, shipped as plain files next to the game.

public sealed class PoLocalizer : ILocalizer
Inheritance
PoLocalizer
Implements
Inherited Members
Extension Methods

Remarks

For ru-RU it reads ru-RU.po (or gettext's ru_RU.po), then ru.po, then the default culture's file. Each file is read once, the first time its language is needed; a missing file is remembered as missing. A file that isn't valid is reported once (event 4002) and treated as missing, so a typo in a translation never stops the game. Translators edit .po files with tools such as Poedit, Weblate or Crowdin, and players can add a language without a new build. See PoCatalog for what's read.

Not thread-safe: use it from the thread that runs the UI.

Constructors

PoLocalizer(AssetConfiguration, string, CultureInfo?, ILogger?)

Localized strings from gettext .po files, one per language, shipped as plain files next to the game.

public PoLocalizer(AssetConfiguration assets, string folder, CultureInfo? defaultCulture = null, ILogger? logger = null)

Parameters

assets AssetConfiguration

The asset configuration whose DefaultAssetContext the files are read from.

folder string

The folder of the files, relative to the asset context, such as Localization.

defaultCulture CultureInfo

The language used when a culture and its parents have no string, or null for none: then a language without a file has no strings here. Leave it out for a layer in a CompositeLocalizer, such as mod files, so its default language doesn't hide the next localizer's strings for the player's language.

logger ILogger

Where an unreadable file is reported, or null.

Remarks

For ru-RU it reads ru-RU.po (or gettext's ru_RU.po), then ru.po, then the default culture's file. Each file is read once, the first time its language is needed; a missing file is remembered as missing. A file that isn't valid is reported once (event 4002) and treated as missing, so a typo in a translation never stops the game. Translators edit .po files with tools such as Poedit, Weblate or Crowdin, and players can add a language without a new build. See PoCatalog for what's read.

Not thread-safe: use it from the thread that runs the UI.

Methods

Localize(string, CultureInfo)

Gets the string for key in culture.

public string? Localize(string key, CultureInfo culture)

Parameters

key string

The key. A key with a context is context + '\u0004' + key, as gettext stores it.

culture CultureInfo

The language to localize into.

Returns

string

The string, or null when this localizer has none: the caller decides what to show. Implementations try culture's parents (ru-RU, then ru) when their source supports it.