wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run

ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
  1804 vars into 126 states, 64 into lets; 23498 edits in 460 files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 5ffe50ed02
commit 19fcf60599
459 changed files with 17862 additions and 17603 deletions

View file

@ -1,43 +1,43 @@
# use.ludic - choosing a language: its file loaded into the lookups, and the font atlas it names
export function i18n_use(code: string) -> void {
if codes == null { i18n_init() }
on = false
cur = "en"
var k = i18n_index(code)
export function i18n_use(i18n_st: mut I18nState, code: string) -> void {
if i18n_st.codes == null { i18n_init(i18n_st) }
i18n_st.on = false
i18n_st.cur = "en"
var k = i18n_index(i18n_st, code)
let forced = I18nWorld.forced()
if len(forced) > 0 { k = i18n_index(forced) }
if len(forced) > 0 { k = i18n_index(i18n_st, forced) }
var font = ""
if k > 0 {
let text = Fs.read_text(paths[k])
let text = Fs.read_text(i18n_st.paths[k])
if text != null {
i18n_load_text(text)
on = true
cur = codes[k]
font = fonts[k]
i18n_load_text(i18n_st, text)
i18n_st.on = true
i18n_st.cur = i18n_st.codes[k]
font = i18n_st.fonts[k]
}
}
# the atlas follows the language, and is only reloaded when it actually changes
if len(font) == 0 { font = font_default }
if I18nWorld.font_ready() and not (font == font_now) {
if I18nWorld.set_font(font) { font_now = font } else if not (font_now == font_default) {
I18nWorld.set_font(font_default)
font_now = font_default
if len(font) == 0 { font = i18n_st.font_default }
if I18nWorld.font_ready() and not (font == i18n_st.font_now) {
if I18nWorld.set_font(font) { i18n_st.font_now = font } else if not (i18n_st.font_now == i18n_st.font_default) {
I18nWorld.set_font(i18n_st.font_default)
i18n_st.font_now = i18n_st.font_default
}
}
}
# a .po's text as the lookups, whatever the language is called (a test, a file from elsewhere)
export function i18n_load_text(text: string) -> void {
export function i18n_load_text(i18n_st: mut I18nState, text: string) -> void {
let es = i18n_parse(text)
exact = Dict.new()
out = new []string
cache = Dict.new()
cache_out = new []string
caps = new []string
for c in 0 .. CAPS { push(caps, "") }
plural = Dict.new()
forms = new []string
plural_rule = plural_rule_of(i18n_header(text, "Plural-Forms"))
i18n_st.exact = Dict.new()
i18n_st.out = new []string
i18n_st.cache = Dict.new()
i18n_st.cache_out = new []string
i18n_st.caps = new []string
for c in 0 .. CAPS { push(i18n_st.caps, "") }
i18n_st.plural = Dict.new()
i18n_st.forms = new []string
i18n_st.plural_rule = plural_rule_of(i18n_header(text, "Plural-Forms"))
var np = 0
var nlit = 0
for i in 0 .. len(es) {
@ -48,33 +48,33 @@ export function i18n_load_text(text: string) -> void {
nlit += h + 1
}
}
pat_out = new []string
lits = new []string
pat_l0 = words(np + 1)
pat_nl = words(np + 1)
pat_sc = words(np + 1)
pat_ph = words(nlit + 1)
nx_p = words(np + 1)
nx_s = words(np + 1)
nx_g = words(np + 1)
pfx = Dict.new()
sfx = Dict.new()
gen_head = 0
pat_n = 0
i18n_st.pat_out = new []string
i18n_st.lits = new []string
i18n_st.pat_l0 = words(np + 1)
i18n_st.pat_nl = words(np + 1)
i18n_st.pat_sc = words(np + 1)
i18n_st.pat_ph = words(nlit + 1)
i18n_st.nx_p = words(np + 1)
i18n_st.nx_s = words(np + 1)
i18n_st.nx_g = words(np + 1)
i18n_st.pfx = Dict.new()
i18n_st.sfx = Dict.new()
i18n_st.gen_head = 0
i18n_st.pat_n = 0
for i in 0 .. len(es) {
let e = es[i]
if len(e.plural) > 0 { plural_add(e) } else if not (blank(e.id) or blank(e.str)) {
if holes(e.id) > 0 { add_pattern(e.id, e.str) } else {
Dict.set(exact, e.id, len(out))
push(out, e.str)
if len(e.plural) > 0 { plural_add(i18n_st, e) } else if not (blank(e.id) or blank(e.str)) {
if holes(e.id) > 0 { add_pattern(i18n_st, e.id, e.str) } else {
Dict.set(i18n_st.exact, e.id, len(i18n_st.out))
push(i18n_st.out, e.str)
}
}
}
on = true
i18n_st.on = true
}
# English again: nothing loaded, nothing translated
export function i18n_off() -> void {
on = false
cur = "en"
export function i18n_off(i18n_st: mut I18nState) -> void {
i18n_st.on = false
i18n_st.cur = "en"
}