wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -1,26 +1,26 @@
|
|||
# translate.ludic - what the game draws, in the language in use: exact, else a pattern, else the
|
||||
# padding a layout put round it taken off, else a paragraph a sentence at a time; English otherwise
|
||||
export function L(s: string) -> string {
|
||||
if not on { return s }
|
||||
let ci = Dict.get_or(cache, s, -1)
|
||||
if ci >= 0 { return cache_out[ci] }
|
||||
let r = whole(s)
|
||||
if Dict.size(cache) >= CACHE_MAX {
|
||||
Dict.clear(cache)
|
||||
cache_out = new []string
|
||||
export function L(i18n_st: mut I18nState, s: string) -> string {
|
||||
if not i18n_st.on { return s }
|
||||
let ci = Dict.get_or(i18n_st.cache, s, -1)
|
||||
if ci >= 0 { return i18n_st.cache_out[ci] }
|
||||
let r = whole(i18n_st, s)
|
||||
if Dict.size(i18n_st.cache) >= CACHE_MAX {
|
||||
Dict.clear(i18n_st.cache)
|
||||
i18n_st.cache_out = new []string
|
||||
}
|
||||
Dict.set(cache, s, len(cache_out))
|
||||
push(cache_out, r)
|
||||
Dict.set(i18n_st.cache, s, len(i18n_st.cache_out))
|
||||
push(i18n_st.cache_out, r)
|
||||
return r
|
||||
}
|
||||
|
||||
function whole(s: string) -> string {
|
||||
function whole(i18n_st: mut I18nState, s: string) -> string {
|
||||
let n = len(s)
|
||||
if n == 0 { return s }
|
||||
let e = Dict.get_or(exact, s, -1)
|
||||
if e >= 0 { return out[e] }
|
||||
let r = pattern(s, 0)
|
||||
if hit { return r }
|
||||
let e = Dict.get_or(i18n_st.exact, s, -1)
|
||||
if e >= 0 { return i18n_st.out[e] }
|
||||
let r = pattern(i18n_st, s, 0)
|
||||
if i18n_st.hit { return r }
|
||||
# the padding a layout put round a word: " owned"
|
||||
var a = 0
|
||||
var b = n
|
||||
|
|
@ -29,15 +29,15 @@ function whole(s: string) -> string {
|
|||
if a > 0 or b < n {
|
||||
if b <= a { return s }
|
||||
let core: string = s[a..b]
|
||||
let t = whole(core)
|
||||
let t = whole(i18n_st, core)
|
||||
if t == core { return s }
|
||||
return s[0..a] + t + s[b..n]
|
||||
}
|
||||
return sentences(s)
|
||||
return sentences(i18n_st, s)
|
||||
}
|
||||
|
||||
# a paragraph built from sentences, one at a time; English stays where a sentence is unknown
|
||||
function sentences(s: string) -> string {
|
||||
function sentences(i18n_st: mut I18nState, s: string) -> string {
|
||||
let n = len(s)
|
||||
var r = ""
|
||||
var start = 0
|
||||
|
|
@ -47,8 +47,8 @@ function sentences(s: string) -> string {
|
|||
while i < n - 1 {
|
||||
let c = s[i]
|
||||
if (c == 46 or c == 33 or c == 63) and s[i + 1] == 32 {
|
||||
let t = sentence(s[start..i + 1])
|
||||
if hit { any = true }
|
||||
let t = sentence(i18n_st, s[start..i + 1])
|
||||
if i18n_st.hit { any = true }
|
||||
r = r + t + " "
|
||||
start = i + 2
|
||||
pieces += 1
|
||||
|
|
@ -58,18 +58,18 @@ function sentences(s: string) -> string {
|
|||
i += 1
|
||||
}
|
||||
if pieces == 0 { return s }
|
||||
let t = sentence(s[start..n])
|
||||
if hit { any = true }
|
||||
let t = sentence(i18n_st, s[start..n])
|
||||
if i18n_st.hit { any = true }
|
||||
if not any { return s }
|
||||
return r + t
|
||||
}
|
||||
|
||||
function sentence(p: string) -> string {
|
||||
hit = false
|
||||
let e = Dict.get_or(exact, p, -1)
|
||||
function sentence(i18n_st: mut I18nState, p: string) -> string {
|
||||
i18n_st.hit = false
|
||||
let e = Dict.get_or(i18n_st.exact, p, -1)
|
||||
if e >= 0 {
|
||||
hit = true
|
||||
return out[e]
|
||||
i18n_st.hit = true
|
||||
return i18n_st.out[e]
|
||||
}
|
||||
return pattern(p, 0)
|
||||
return pattern(i18n_st, p, 0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue