ludic.i18n: a language's lookups kept once read; switching back restores them
i18n_use re-read and re-parsed the .po on every change of language (ev_SettingsChanged, SetLang) and dropped the old tables for good: the play of 22 minutes left lines_of 650 KB, fs_read_text 409 KB, PoEntry 113 KB and unquote 273 KB unreachable, and three of its @alloc_ok sites were declared but unbounded. Each language's tables are now filed by index once built (tables.ludic, I18nTables) and put back by reference; a new probe (i18n_init) or a different file for a code (lang_add) reads it again. Test: a language switched back to is its kept tables, not its file read again; a new probe reads it (9 tests pass). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
28ad6f62ea
commit
1667d7f16e
6 changed files with 112 additions and 1 deletions
|
|
@ -7,10 +7,16 @@ export function i18n_use(i18n_st: mut I18nState, code: string) -> void {
|
|||
let forced = I18nWorld.forced()
|
||||
if len(forced) > 0 { k = i18n_index(i18n_st, forced) }
|
||||
var font = ""
|
||||
if k > 0 {
|
||||
if k > 0 and tables_have(i18n_st, k) {
|
||||
tables_put(i18n_st, i18n_st.tabs[k])
|
||||
i18n_st.on = true
|
||||
i18n_st.cur = i18n_st.codes[k]
|
||||
font = i18n_st.fonts[k]
|
||||
} else if k > 0 {
|
||||
let text = Fs.read_text(i18n_st.paths[k])
|
||||
if text != null {
|
||||
i18n_load_text(i18n_st, text)
|
||||
tables_file(i18n_st, k)
|
||||
i18n_st.on = true
|
||||
i18n_st.cur = i18n_st.codes[k]
|
||||
font = i18n_st.fonts[k]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue