Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in Locales #26

Open
MTrop opened this issue Mar 11, 2019 · 0 comments
Open

Built-in Locales #26

MTrop opened this issue Mar 11, 2019 · 0 comments
Labels
enhancement Nice-to-haves and things that can actually help current behavior.
Milestone

Comments

@MTrop
Copy link
Member

MTrop commented Mar 11, 2019

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.
@MTrop MTrop added the enhancement Nice-to-haves and things that can actually help current behavior. label Mar 11, 2019
@MTrop MTrop added this to the v1.0 milestone Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Nice-to-haves and things that can actually help current behavior.
Development

No branches or pull requests

1 participant