40 lines
1.3 KiB
Text
40 lines
1.3 KiB
Text
# tables.ludic - a language's lookups, kept once read: switching back to it is a copy of references,
|
|
# not the .po parsed again (every change of language once dropped the old tables for good)
|
|
property I18nTables {
|
|
exact: Dict = null
|
|
out: []string = null
|
|
plural: Dict = null
|
|
forms: []string = null
|
|
plural_rule: int = 0
|
|
}
|
|
|
|
@alloc_ok("once per language: its lookups, kept")
|
|
function tables_keep(i18n_st: I18nState) -> I18nTables {
|
|
let t = new I18nTables
|
|
t.exact = i18n_st.exact
|
|
t.out = i18n_st.out
|
|
t.plural = i18n_st.plural
|
|
t.forms = i18n_st.forms
|
|
t.plural_rule = i18n_st.plural_rule
|
|
return t
|
|
}
|
|
|
|
function tables_put(i18n_st: mut I18nState, t: I18nTables) -> void {
|
|
i18n_st.exact = t.exact
|
|
i18n_st.out = t.out
|
|
i18n_st.plural = t.plural
|
|
i18n_st.forms = t.forms
|
|
i18n_st.plural_rule = t.plural_rule
|
|
}
|
|
|
|
function tables_have(i18n_st: I18nState, k: int) -> bool {
|
|
if i18n_st.tabs == null or k >= len(i18n_st.tabs) { return false }
|
|
return i18n_st.tabs[k] != null
|
|
}
|
|
|
|
@alloc_ok("once per language: the slot its lookups are kept in")
|
|
function tables_file(i18n_st: mut I18nState, k: int) -> void {
|
|
if i18n_st.tabs == null { i18n_st.tabs = new []I18nTables }
|
|
while len(i18n_st.tabs) <= k { push(i18n_st.tabs, null) }
|
|
i18n_st.tabs[k] = tables_keep(i18n_st)
|
|
}
|