Catalog
#struct CatalogA catalog of translations. Build one with New and release it with Free.
| Name | Type | Description |
|---|---|---|
keys | Vector<str> | The stored keys, in the form "language:key". |
vals | Vector<str> | The translations, in the same order as the keys. |
fallback | str = "en" | The fallback language. |
import i18n
func main:
mut c := i18n.New("en")
defer i18n.Free(c)
i18n.Set(c, "en", "hello", "Hello")
i18n.Set(c, "fa", "hello", "سلام")
i18n.Set(c, "en", "bye", "Goodbye")
println i18n.T(c, "fa", "hello"), i18n.T(c, "fa", "bye"), i18n.T(c, "fa", "missing")
println i18n.Has(c, "fa", "bye"), i18n.RawGet(c, "fa", "bye") == ""
println c.fallback
endسلام Goodbye missing false true en