Sign in

    moui_i18n

    Pure target-neutral internationalization addon for MoUI

    moui
    i18n
    localization
    translation
    Download zip
    Author
    Version
    0.2.1
    License
    Apache-2.0
    Last updated
    5 days ago
    Downloads
    10

    wzzc-dev/moui_i18n does not have a README file

    Catalog

    pub struct Catalog {
    messages : Map[String, Map[String, String]]
    }

    An in-memory catalog indexed by canonical locale and message key.

    Catalog::from_entries

    fn Catalog::from_entries(entries : ArrayView[Message]) -> Catalog

    Builds a catalog from static message entries. Entries with invalid locale identifiers are ignored. Later entries replace earlier entries with the same locale and key.

    Locale

    pub struct Locale {
    language : String
    script : String?
    region : String?
    }

    A normalized locale identifier consisting of a language and optional script and region subtags.

    Locale::canonical

    fn Locale::canonical(self : Locale) -> String

    Returns the canonical locale string, such as zh-Hans-CN.

    Locale::fallback_candidates

    fn Locale::fallback_candidates(self : Locale) -> Array[String]

    Returns deterministic lookup candidates from most to least specific. A locale with both script and region falls back through language-script and then language.

    Locale::language

    fn Locale::language(self : Locale) -> String

    Returns the canonical language subtag.

    Locale::parse

    fn Locale::parse(raw : String) -> Locale?

    Parses a locale identifier with a language and optional script and region. Both - and _ separators are accepted. Canonical locale casing uses a lowercase language, titlecase script, and uppercase region.

    Locale::region

    fn Locale::region(self : Locale) -> String?

    Returns the canonical region subtag when supplied.

    Locale::script

    fn Locale::script(self : Locale) -> String?

    Returns the canonical script subtag when supplied.

    Message

    pub(all) struct Message {
    locale : String
    key : String
    value : String
    }

    A static translation entry in a catalog.

    Message::new

    fn Message::new(locale~ : String, key~ : String, value~ : String) -> Message

    Constructs a static translation entry.

    Translator

    pub struct Translator {
    catalog : Catalog
    locale : Locale
    default_locale : Locale
    }

    Resolves messages from a catalog using requested and default locale fallback candidates.

    Translator::new

    fn Translator::new(catalog~ : Catalog, locale~ : Locale, default_locale~ : Locale) -> Translator

    Creates a translator for a catalog, requested locale, and default locale.

    Translator::translate

    fn Translator::translate(self : Translator, key : String, values? : ArrayView[(String, String)]) -> String

    Translates a message key and interpolates named values. Missing messages return a nonfatal [[key]] marker.

    Translator::translate_count

    fn Translator::translate_count(self : Translator, key : String, count : Int, values? : ArrayView[(String, String)]) -> String

    Translates a plural message. English selects .one when count == 1 and .other otherwise; Chinese always selects .other. The count value is always available as the {count} placeholder.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io