Skip to content

sonolus.script.metadata

AnyText = str | LocalizationText

Text given either as a plain string or as a localization dict.

Locale = Literal['el', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'pt', 'ru', 'tr', 'vi', 'zhs', 'zht']

A locale code supported by Sonolus.

These are the codes from the Sonolus locale list: el (Greek), en (English), es (Spanish), fr (French), id (Indonesian), it (Italian), ja (Japanese), ko (Korean), pt (Portuguese), ru (Russian), tr (Turkish), vi (Vietnamese), zhs (Simplified Chinese), and zht (Traditional Chinese).

LocalizationText = dict[Locale | str, str]

Text localized per locale.

Keys are usually locale codes, but any string key is accepted and unrecognized keys are not validated.

Tag

A tag for an engine or level.

Parameters:

Name Type Description Default
title AnyText

The title of the tag.

required
icon str | None

The icon of the tag.

None

as_localization_text(text: AnyText) -> LocalizationText

Convert text into a localization dict, treating a plain string as en.

encode_localization_text(text: AnyText | None) -> str | None

encode_localization_text(text: AnyText) -> str
encode_localization_text(text: None) -> None
encode_localization_text(
    text: AnyText | None,
) -> str | None

Encode text into a single string for fields that only accept strings.

A localization dict maps locale codes to text, and is encoded as ##LOCALIZE: followed by compact JSON, e.g. ##LOCALIZE:{"en":"Hello World","zhs":"你好世界"}, for supporting servers to expand. Plain strings and None pass through unchanged.

Item metadata such as Engine and Level titles supports localization dicts natively and does not use this encoding.