ludic.i18n: keys (phase 26.1) - en.po as the base, tr/trf/trn marked strings made into text by L, keyed plurals, the fallback to English then the key ([[key]] loud in a dev build), the English form beside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
82c652ca31
commit
f0096aec87
10 changed files with 355 additions and 4 deletions
|
|
@ -37,6 +37,26 @@ the `.po`, for a script the default atlas does not carry; `Plural-Forms` picks t
|
|||
|
||||
Whatever has no translation draws in English, so a partial file is always playable.
|
||||
|
||||
## Keys (phase 26: the form that replaces English in the code)
|
||||
|
||||
A key names what a text is FOR (`pause.resume`), and `assets/lang/en.po` says what it says in English,
|
||||
like any other language. A key travels as a string with a marker byte in front (the compiler's
|
||||
`k"pause.resume"` is exactly that; `kn"..."` a plural key), so code that makes text never takes the
|
||||
language's state: the text is made where it is drawn, by `L`.
|
||||
|
||||
```ludic
|
||||
L(tr(k"pause.resume")) # "Resume"; "Devam" in Turkish
|
||||
L(trf(k"catch.saw", tr(k"species.elk.a_name"), "5:30", "", "")) # "You saw an elk at 5:30."
|
||||
L(trn(kn"pack.items", n, "", "", "")) # "{1} items" by the language's plural rule
|
||||
```
|
||||
|
||||
- A key's text is the language in use's, else en.po's (read from the languages' directory the first
|
||||
time a key is asked for), else the key itself - `[[key]]` in a developer's build (`i18n_loud`),
|
||||
said once.
|
||||
- Holes `{1}` .. `{4}` take `trf`'s arguments in the language's own order; an argument that is a key
|
||||
is made into its text first. A plural's count is `{1}`.
|
||||
- A string with no marker takes the English path below, so a game moves over a file at a time.
|
||||
|
||||
## Config and port
|
||||
|
||||
```ludic
|
||||
|
|
@ -54,7 +74,10 @@ port I18nWorld {
|
|||
| | |
|
||||
| --- | --- |
|
||||
| `L(s) -> string` | what the game draws, in the language in use (cached) |
|
||||
| `Ln(one, many, n) -> string` | a count's form, with `{1}` the count; English is one for 1, many otherwise |
|
||||
| `Ln(one, many, n) -> string` | a count's form, with `{1}` the count; English is one for 1, many otherwise (the old form) |
|
||||
| `tr(k)`, `trf(k, a, b, c, d)`, `trn(k, n, a, b, c) -> string` | a key, a key with its holes' arguments, a plural key by `n`: made into text by `L` |
|
||||
| `i18n_key(name)`, `i18n_key_plural(name)`, `key_text(k)`, `i18n_is_key(s)` | a key named at run time, its name without the marker, whether a string is one |
|
||||
| `i18n_base_text(text)`, `i18n_loud(on)` | the base (en.po) from text, for a test; a developer's build's loud missing key |
|
||||
| `i18n_init()`, `i18n_count()`, `i18n_index(code)`, `i18n_code_at(i)`, `i18n_name_at(i)`, `i18n_font_at(i)`, `i18n_mod_dir()` | the languages found, "en" first |
|
||||
| `i18n_use(code)`, `i18n_off()`, `i18n_on()`, `i18n_current()` | choosing one; whether anything is translating |
|
||||
| `i18n_font_base(dir)`, `i18n_font_now()` | the atlas the overlay was opened with, and the one it has now |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue