Skip to content

Built-in Locales #26

@MTrop

Description

@MTrop

TAME Language Block

<LangKeyvalueList> := 
    <IDENTIFIER> "=" <Value> ";" <LangKeyvalueList>
    [e]

<LangListPrime> :=
    "," <LangList>
    [e]
    
<LangList> :=
    <STRING> <LangListPrime>
    
<LocaleDefinition> := locale <LangList> "{" <LangKeyvalueList> "}"

locale [langcode]
{
    KEY = "VALUE";
}

Serialized as Key-Value pairs after header.

  • Key is (case-insensitive) string.
  • Value is string.

Headers to Add

tame_default_locale = [STRING];

Used internally as the fallback locale when keys are not found. If none specified, this is "default".

Runtime Features to Add

--locale [arg] - Force origin locale to [arg]. Find it if not specified.

Example

module
{
    title = "language test";
}

locale "en", "default"
{
    greeting = "Hello!"
}

locale "sp"
{
    greeting = "Buenos dias!"
}

world
{
    start()
    {
        textln(strlocale("greeting"));
    }
}

What Does this Help?

Writing localized modules. The text strings are separated out of the main code, allowing for better localization strategy without changing game code.

+TLocaleTable
    keyMap: HashMap<String, HashMap<String, String>> // locale to key-value map.
    // Make case-insensitive keys
    (Add to module serialization)

>TModuleContext
    +localeLanguage : String
    +localeCountry : String
    (Add to state save)

>TAMEOperation
    +STRLOCALE(Value)
        Value: A value coerced to string.
        RETURN: The value that corresponds to the key (string). Key is case-insensitive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNice-to-haves and things that can actually help current behavior.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions