Skip to main content
WindUI’s localization system maps translation keys to strings for any number of languages. When a language is active, every element whose Title (or other text property) starts with the configured prefix is replaced with the matching translation at render time and whenever SetLanguage is called.

How it works

Localization is opt-in. You call WindUI:Localization(config) once at startup to register your translations. After that, pass keys prefixed with "loc:" (the default prefix) as element titles, and WindUI replaces them with the correct string for the active language. If a key has no translation for the current language, WindUI falls back to the "en" translations. If that also has no entry, it renders the raw key in brackets: [my-key]. The initial language is set to Creator.Language when WindUI loads. You can override it at any time by calling WindUI:SetLanguage(code).

Setting up localization

1

Call WindUI:Localization() with your translation table

Call this before creating any elements that use localization keys. The Translations table maps a language code to a dictionary of key → string pairs.
WindUI:Localization({
    Enabled = true,
    DefaultLanguage = "en",
    Prefix = "loc:",
    Translations = {
        en = {
            ["toggle-title"]   = "Enable Feature",
            ["toggle-desc"]    = "Turns the feature on or off",
            ["slider-title"]   = "Speed",
            ["button-title"]   = "Execute",
            ["input-title"]    = "Target Name",
            ["section-title"]  = "Main Settings",
        },
        ru = {
            ["toggle-title"]   = "Включить функцию",
            ["toggle-desc"]    = "Включает или выключает функцию",
            ["slider-title"]   = "Скорость",
            ["button-title"]   = "Выполнить",
            ["input-title"]    = "Имя цели",
            ["section-title"]  = "Основные настройки",
        },
        fr = {
            ["toggle-title"]   = "Activer la fonctionnalité",
            ["toggle-desc"]    = "Active ou désactive la fonctionnalité",
            ["slider-title"]   = "Vitesse",
            ["button-title"]   = "Exécuter",
            ["input-title"]    = "Nom de la cible",
            ["section-title"]  = "Paramètres principaux",
        },
    },
})
2

Use loc: keys as element titles

Prefix any element title with "loc:" followed by the translation key. WindUI resolves it to the active language’s string automatically.
local Tab = Window:Tab({ Title = "Settings" })

Tab:Section({ Title = "loc:section-title" })

Tab:Toggle({
    Title = "loc:toggle-title",
    Desc  = "loc:toggle-desc",
    Callback = function(state)
        print("toggled:", state)
    end,
})

Tab:Slider({
    Title = "loc:slider-title",
    Step = 1,
    Value = { Min = 0, Max = 100, Default = 50 },
    Callback = function(value)
        print("speed:", value)
    end,
})

Tab:Button({
    Title = "loc:button-title",
    Justify = "Center",
    Icon = "",
    Callback = function() end,
})

Tab:Input({
    Title = "loc:input-title",
    Placeholder = "...",
    Callback = function(v) end,
})
3

Switch languages at runtime

Call WindUI:SetLanguage(code) at any point to re-render all registered text objects in the new language.
Tab:Dropdown({
    Title = "Language",
    Values = { "en", "ru", "fr" },
    Value = "en",
    Callback = function(lang)
        WindUI:SetLanguage(lang)
    end,
})
SetLanguage delegates to Creator.SetLanguage, which iterates every registered localization object and updates its .Text property immediately.

LocalizationConfig fields

FieldTypeDefaultDescription
EnabledbooleanfalseMust be true for localization to take effect.
Translationstable{}Map of language code → { [key] = string }.
Prefixstring"loc:"Prefix that marks a string as a translation key.
DefaultLanguagestring"en"Fallback language when a key is missing in the active language.

Fallback behaviour

  1. Look up the key in the active language’s table.
  2. If not found, look up the key in the "en" table.
  3. If still not found, render [key].
The initial language is set via Creator.Language inside WindUI. Call WindUI:SetLanguage(code) to switch languages at any time after loading.

Custom prefix

If "loc:" conflicts with your own naming, change Prefix to any string you like.
WindUI:Localization({
    Enabled = true,
    Prefix = "t:",
    Translations = {
        en = { ["hello"] = "Hello!" },
        es = { ["hello"] = "¡Hola!" },
    },
})

-- In an element:
Tab:Button({ Title = "t:hello", Callback = function() end })
Call WindUI:Localization(...) before creating any elements that use localization keys. Objects created before localization is enabled are not retroactively registered.

Build docs developers (and LLMs) love