Audamir

part 56

How Audamir is translated today: constructions in a text, loading and file sizes over time

Translations today: what one text may contain (parameter, plural, gender, nesting), how texts load into memory, and how the file sizes changed in 19 days, with numbers from git.

· 19 min read

The article Five languages, one gender and the H key that did not work says why “5 dice” is not “2 dice” and how the game avoids the gender of the player. This one is about what a translation of the game is made of: what one text may contain, how the texts get into the memory of the page, and how their storage changed in 19 days, from two files to 81. The five steps of 31 October and 1 November are described in Texts as trees; here each of them is only a sentence and a number.

The state is Audamir 0.124.0 of 6 November 2026. The numbers come from git and from the tools of the game, with the commands in the sources at the end; what is an estimate or an explanation is marked as such. This article is reading the code and measuring git; the game was not changed.

Four words come up again and again. Key is the name of a text (core.settings.dice_count). Catalogue is a table of key → text for one language. Pack is a part of the game with its own texts: the core, a realm or the game (nine today, for example core, kastgard/stacks, rokgard/colony), and the owner of a key is the pack that defines it. Manager (in the code I18n) joins the files of the packs into catalogues and looks things up in them.

From two files to trees: sizes over time

The git history of the game starts on 18 October 2026, and already then the texts are split by language: en.js and sk.js, 313 kB together. An earlier single big file with everything is not in git; if it existed, it was before the first commit. What is in git is eight changes and their size in bytes (the files js/i18n/<language>.js and js/realms/**/i18n/<language>.js, without the code of the manager):

PointWhat changedFilesKeysTotalLargest
18 Octfirst commit: en, sk21,883313 kB157 kB
19 Oct+ cs, sr, ru52,5881,162 kB310 kB
19 Octpacks of languages52,5881,162 kB310 kB
22 Oct+ es, pt-br, fr, de93,4342,765 kB412 kB
30 Oct, game 0.63.7before the split93,7273,024 kB452 kB
31 Oct, game 0.65.6first packs363,7903,100 kB445 kB
31 Oct, game 0.70.3trees and Kastgard813,8063,190 kB195 kB
1 Nov, game 0.84.0after the trees813,8653,238 kB180 kB
6 Nov, game 0.124.0today814,1963,481 kB201 kB
Size of the files with the texts of the game Audamir from 18 October to 6 November 2026Eight horizontal bars, each the sum of the bytes of the files with texts in one commit of the game. The first commit of 18 October has 2 files and 313 kB, today's commit has 81 files and 3 481 kB. The biggest file went down from 452 kB to 195 kB when the packs were split on 31 October. Colours of a bar: English, Slovak and the other languages.18 Octfirst commit313 kB2 files · largest 157 kB · 1 883 keys in English19 Octcs, sr, ru1 162 kB5 files · largest 310 kB · 2 588 keys in English22 Octes, pt-br, fr, de2 765 kB9 files · largest 412 kB · 3 434 keys in English30 Oct · 0.63.7before the split3 024 kB9 files · largest 452 kB · 3 727 keys in English31 Oct · 0.65.6first packs3 100 kB36 files · largest 445 kB · 3 790 keys in English31 Oct · 0.70.3trees, Kastgard3 190 kB81 files · largest 195 kB · 3 806 keys in English1 Nov · 0.84.0after the trees3 238 kB81 files · largest 180 kB · 3 865 keys in English6 Nov · 0.124.0today3 481 kB81 files · largest 201 kB · 4 196 keys in EnglishEnglishSlovakother languagesSum of the files with the texts of the languages, without the code of the manager. 1 kB = 1,000 bytes.
Size of the files with texts in eight commits of the game (18 Oct to 6 Nov 2026), from git ls-tree -l and git cat-file. The sum of the bytes of the files with texts without the code of the manager; under the bar are the number of files, the biggest file and the number of English keys. 1 kB = 1,000 bytes.

The first bar of the figure has English and Slovak almost the same size. The more languages, the more grey: the other seven languages (cs, sr, ru, es, pt-br, fr, de) make up 2,771 kB of 3,481 kB today, that is 80 %.

What the numbers say, and what they do not:

  • The sum grew elevenfold (313 → 3,481 kB), but not because the texts became bigger. There are 2.2 times more keys (1,883 → 4,196) and 4.5 times more languages (2 → 9). One English key takes 80 to 84 bytes of a file at each point (82.6 at the start, 80.9 before the split, 83.8 after the trees, 82.9 today). The size follows the number of keys times the number of languages. After gzip (each file separately) it is 90 kB at the start and 987 kB today.
  • Splitting into packs did not shrink the whole, it shrank the biggest file. From 19 October the biggest file is always the Russian one, because Cyrillic takes two bytes per letter: 452 kB on 30 October, 195 kB after the split, 201 kB today. The biggest English file today is the core, 139 kB. There are 81 files instead of nine, and the headers (the comment and the wrapper of the file) take 60 kB, that is 1.7 % of the whole; before the split they were 4 kB.
  • The tree is not smaller. The analysis of 30 October (docs/I18N-SPLIT.md, 3.3) measured that a nested tree saves 4.3 % of the bytes of English and 3.1 % after gzip; in that day's question a file that is “smaller and clearer” was awaited. But then the path of the pack was added to every key, and one leaf per line. The result in git: 80.9 → 83.8 bytes per English key, that is 3.6 % more. The headers of the 81 files make up half of it; without them it is 80.8 → 82.3 bytes (1.8 % more), and today 81.4. The cause of the rest was not measured (the candidates are the prefix of the pack in every path, the indentation of deep levels and the comments of the groups). It is clearer, and that was the point; not smaller.
  • The sum in the repository is not what the page loads. Before the commit of 19 October the page loaded all five catalogues (7 files, 1,178 kB); from it on, English and one language: in English 4 files and 226 kB, in Slovak 5 files and 441 kB. Today it depends on whether the source files or the built game are meant; the section on loading is about that.

The first packs were made on 31 October for the realm that was then called Taflgard and is now called Rokgard; trees and Kastgard the same day. These are steps S1 and S2 from Texts as trees.

Everything one text may contain

A text in a catalogue is a plain string. Curly brackets in it may be of four kinds: a parameter, a plural group, a gender group and a group inside a group. The rules are in the introductory comment of js/i18n/i18n.js. Of the 4,196 texts, 915 have a parameter, 236 (English and Spanish) to 272 (French) a plural group, and 85 in Slovak, 81 in Czech, 78 in Serbian and 60 in Russian a gender group. English has no gender group at all. The examples are from the catalogues of the game.

Parameter {name}

A word in brackets that the game replaces with a value, for example in the Slovak text of core.hub.stats.text: {played} {played#hra|hry|hier} · {pct} výhier. A parameter that is missing stays in the text ({x}), undefined is printed as undefined and null as null, as a JavaScript template string does.

Every language has the same parameters as English.

Plural group {n#a|b|c}

After # come the forms from the first to the last, and the one that is chosen depends on the number and on the rule of the language. The rule has a name in packs.js (plural), and there are four:

RuleLanguagesForms
twoen, es, de1 \other
zero-onefr, pt-brbelow 2 \other
west-slavicsk, cs1 \2 to 4 \other
east-slavicsr, ru1, 21 … \2 to 4, 22 … \other

Details of the Russian rule are in Five languages, one gender and the H key that did not work; here is a different text and what the game makes of it (core.settings.dice_count, the output of a call of t over the real catalogues):

en  {k} {k#die|dice}
    0 dice · 1 die · 2 dice
de  {k} {k#Würfel|Würfel}
    1 Würfel · 2 Würfel
fr  {k} {k#dé|dés}
    0 dé · 1 dé · 1.5 dé · 2 dés
sk  {k} {k#kocka|kocky|kociek}
    1 kocka · 2 kocky · 5 kociek
    21 kociek
ru  {k} {k#кубик|кубика|кубиков}
    1 кубик · 2 кубика · 5 кубиков
    11 кубиков · 21 кубик

Three things are worth noticing. German has two identical forms: a group must always have at least two. If a group has fewer forms than the rule asks for, the last one is taken. And the group only chooses a form: a fraction is printed as it arrives (1.5 with a point), and the decimal comma is made only by I18n.decimal.

Czech, Serbian and Russian have exactly three forms.

Gender group {gender#…}

Three forms: for a man, for a woman and for nobody in particular. Gender is not a parameter but the setting Gender[1] (m, f, n, default n), which is read when the page loads, as the language is, so the page loads again after the setting is changed. The third form is the text as it was before gender existed, so whoever chose nothing sees no change. A form may be a whole sentence (core.app.eliminated_text; broken into lines here, in the file the group is on one line):

sk  {gender#
      Bol si vyradený v {round}. kole.
        Skús to znova.|
      Bola si vyradená v {round}. kole.
        Skús to znova.|
      Vyradenie v {round}. kole.
        Skús to znova.}
    muž:  Bol si vyradený v 7. kole.
    žena: Bola si vyradená v 7. kole.
    inak: Vyradenie v 7. kole.
ru  Тебя выбили в раунде {round}.
    Попробуй снова.
en  You were eliminated in round
    {round}. Try again.

The language chooses the gender group, not the key: the same key has three forms in Slovak, Czech and Serbian, and in Russian a sentence that goes around gender. English has no gender anywhere, and the pack says so (genders: false in packs.js), which also hides the line of the setting.

A group inside a group

A gender group is not found by a pattern but by counting brackets: scanGender follows the depth of { and }, and the forms are split by the bar | only on the first level. So inside a form there may be anything, even a plural group. First the gender is chosen, then the other groups are filled in. In the catalogues there are two to three of them in each of Slovak, Czech, Serbian and Russian, and none in the other languages (core.die.result_boxes in Czech and Russian):

cs  {gender#
      Otevřel jsi {n}
        {n#krabici|krabice|krabic}: {faces}.|
      Otevřela jsi {n}
        {n#krabici|…}: {faces}.|
      Otevřeno: {n} {n#krabice|…} – {faces}.}
    žena, 3: Otevřela jsi 3 krabice: …
    muž, 5:  Otevřel jsi 5 krabic: …
ru  muž, 21:  Ты открыл 21 коробку: …
    žena, 2:  Ты открыла 2 коробки: …
    inak, 12: Открыто: 12 коробок – …

A missing key and a stored key

A key that is missing in a language is taken from English; if it is not there either, the game returns the key itself and writes it into I18n.missing. When core.hub.stats.text is deleted from Slovak, 5 games · 40 % wins is shown; when it is deleted from English too, core.hub.stats.text is shown. This should not happen in the game, because every key the code uses is in the catalogues. One detail from this experiment: the fallback English text is filled in by the rule of the current language, so the Russian catalogue without dice_count gave “21 die” instead of “21 dice” for 21.

Sometimes a key is stored: the record of the game has events such as { k: 'v', key }, so that a saved game is shown in the language that is chosen later. Such a key is wrapped in the code as trk('…') (I18n.key, which only returns the key and marks that it is translated only when shown). If a stored key is renamed, an old game still knows it: the table RENAMED in the manager has two lines, for example events.betray_notice → kastgard.stacks.events.betray_notice, and t('events.betray_notice') shows the text of the new key.

Numbers, percentages and capital letters

I18n.decimal(1.5) gives 1,5 in Slovak, Czech, Serbian, Russian, Spanish, French and German, and 1.5 in English. I18n.percent(56) gives 56 % with a space in Slovak, Czech and Russian, with a no-break space in Spanish, French and German, and 56% without it in English, Serbian and Brazilian Portuguese. It is the template percent in packs.js ('{n} %', '{n}%'). German has the flag capitalNouns: I18n.lower keeps the name of a setting with a capital letter, because German nouns always have one.

A derived and a reference language

Serbian Cyrillic has no catalogue of its own. The entry sr-cyrl in packs.js has derive: 'sr' and scripts: ['js/i18n/translit-sr.js']: the catalogue is made from the Latin one by transliteration at the first use ({played} {played#igra|igre|igara} · {pct} pobeda gives 5 игара · 40% победа), and it is made again when texts are added (the counter generation in the manager). The first use took 72 and 77 ms in a measurement and keeps extra memory. English is reference: true: it is always loaded and is the fallback language of every other one.

The properties of a language in packs.js

A language is one line of the list js/i18n/packs.js. Serbian in Latin and Cyrillic (shortened and broken into lines):

{ id: 'sr', name: 'Srpski',
  locale: 'sr-Latn-RS', htmlLang: 'sr-Latn',
  decimal: ',', percent: '{n}%',
  plural: 'east-slavic', file: 'js/i18n/sr.js',
  beta: true, tags: ['sr-latn', 'sr-me'] },
{ id: 'sr-cyrl', name: 'Српски',
  locale: 'sr-Cyrl-RS', htmlLang: 'sr-Cyrl', …,
  beta: true, derive: 'sr',
  scripts: ['js/i18n/translit-sr.js'],
  tags: ['sr-cyrl', 'sr-rs', 'sr'] },

tags say which browser language this entry selects (sr-RS gives Cyrillic, sr-Latn Latin), htmlLang is the lang of the page if it differs from id, beta marks a draft, file is the catalogue of the core. A new language thus needs nothing else than a file per pack and a line in the list; index.html and the workers read it from the list.

The manager: how texts load and are stored in memory

How the texts get into the memory of the pageSix steps one below another: the page loads the manager and the loader, the language is found, the loader writes the scripts of English and of the chosen language, each file is written to the register, the game asks for a text by its key, and changing the language loads the page again.1The page starts loadingindex.html: three scripts in turn, packs.js (languages),i18n.js (manager) and boot.js (loader)2The language is foundaddress ?lang= → saved setting → browser language→ English (I18n.detect)3The loader writes the scriptsEnglish and the chosen language, one file per pack:source 18 files (710 kB), built game 2 files (537 kB)4A file is written to the registerI18n.add(language, pack, texts): tree → key → text;a key already there is refused and recorded5The game asks for a textI18n.t(key, parameters): language → English → the key;then {parameters}, {n#…} and {gender#…} are filled6Changing the languagesaved in the settings and the page loads again;texts are not swapped while the game runs
How the texts get into the memory of the page: the loading as the code of js/i18n/i18n.js and boot.js does it (game 0.124.0). A scheme read from the code, not a measurement; the numbers in the third step are from a measurement of the files.

1. Three scripts. index.html loads packs.js (list of languages), i18n.js (manager) and boot.js (loader) in this order; every Web Worker does the same. A worker has no language of its own: detect() in it gives English and boot.js loads it through importScripts; it finds its place in js/ from its address (js/worker/x.js is two levels below the root, js/realms/rokgard/games/colony/worker/x.js six).

2. Language. The order in detect(): the variable DW_LANG (only tests and tools in node), the address ?lang=xx (a link from the web of the game; it wins over the saved language), the saved setting, the browser language by tags, English. The saved language is in the setting audamir.settings as cfg.lang; the manager reads it itself, because it loads before the storage of the game. Plain node ignores the language of the computer, so tests stay English.

3. Loader. I18n.packFiles() returns the list of files: English (the core and eight packs) and then the chosen language. boot.js writes document.write('<script src=…>') for each. The written scripts run right after boot.js, in order and before the next script of the page: it is the only way to have the texts before the modules that use them, without an asynchronous start of the whole game, and it also works from a file. A page that is already loaded is left as it is. A file that cannot be loaded is not fatal: its texts fall back to English one by one.

4. Registration. Each file ends with I18n.add(language, pack, texts). The manager flattens the tree to key → text, a key that is already there is refused (the first one stays, and the refusal goes to I18n.conflicts), it writes the owner into I18n.owners and the pack into I18n.sources.

5. Lookup. t(key, parameters) looks in the catalogue of the language, then in English, then in RENAMED, and otherwise returns the key. A text without { and without parameters is returned at once; otherwise it is composed again each time. Apart from the derived Cyrillic nothing is cached: no memory of finished sentences, only a lookup in the object and the replacement of brackets.

6. Changing the language. reloadForLanguage saves the game in progress and the setting, and calls location.reload(). Nothing is swapped while it runs: the texts are made when the modules load, so the page is loaded again.

What the texts hold in the memory of the pageFour registers of the manager at the top: the catalogues of the languages with 4 196 keys, the owners of the keys, the sources and the refused keys, the derived catalogue of Serbian Cyrillic. At the bottom an estimate of the heap: English 2.1 MB, English with Slovak 3.6 MB, with Serbian Cyrillic 4.6 MB, all languages together 15.0 MB.I18N_CATALOGSone flat object, key → text per language:English 4 196 keys, chosen language 4 196 keysOWNERSkey → the pack that gave it (the first wins):4 196 keysSOURCES, CONFLICTSlanguage → the packs that gave it texts (9);refused keys (0)derived catalogueonly Serbian Cyrillic: made from Latin atthe first use, and again when texts are addedEstimate of the heap after the files are loaded (V8, empty context)English2.1 MBEnglish + Slovak3.6 MBEnglish + Serbian Cyrillic4.6 MBall nine languages (tests, tools)15.0 MBEstimate from the V8 heap (heapUsed after collection), not a measurement of the browser.
What the texts hold in memory: the registers of the manager (names from js/i18n/i18n.js) and the heap of V8 (node --expose-gc, heapUsed after two collections, one scenario per process; game 0.124.0). An estimate of the texts, not a measurement of the browser.

What is then in memory

One register per page: the object I18N_CATALOGS with a flat catalogue per language, today English and the chosen language with 4,196 keys each, plus OWNERS (key → pack, also 4,196), SOURCES (language → nine packs) and CONFLICTS. The estimate of the heap, when the files of a language are run in an empty V8 context: 2.1 MB in English, 3.6 MB with two languages, 4.6 MB with Serbian Cyrillic (the derived catalogue is a second object on top) and 15.0 MB when all nine languages are loaded at once, as the tests and tools do. For the built game it is 1.9 MB and 3.1 MB. The number includes everything the scripts leave on the heap; it is an estimate of the texts, not a measurement of the browser.

Service worker and cache

sw.js of the game has only English in its list at installation (in the sources the core and eight packs …/en.js, in the built game i18n/en.js); the other languages are stored when they are first used, because the fetch handler stores every fetched GET from its own origin, in the order “network first, then cache”. Verified in a headless Chromium over the built game (the command audamir-055-sw-cdp.js in the sources):

StepWhat happened
A: first visitEnglish; worker active; the cache of the game (the name carries the version 0.124.0 and the build fingerprint) has i18n.js and i18n/en.js
B: ?lang=ski18n/sk.js (275 kB) is loaded, the cache has the new file, the saved language is sk
C: next visit without the parameterSlovak from the saved setting
D: server off (no network)the page in Slovak from the cache, 4,196 keys
E: no network and saved rui18n/ru.js is not in the cache; the worker answers its request with the file index.html (87,170 bytes), the catalogue ru has 0 keys and all texts are English

This follows from what Five languages, one gender and the H key that did not work already says: the first switch to a new language needs a network. It is now also verified what happens without one: the game does not crash, but speaks English.

Source files against the built game

The development mode (the game runs from the sources without a build) loads each pack as its own file: the page in English has 12 files (nine with texts and three of the manager), in Slovak 21. The built game (tools/build.js) glues the files of a language into one, i18n/<id>.js, and makes them smaller: the page loads i18n.js (list of languages, manager and loader, 9.7 kB), i18n/en.js and i18n/<language>.js. The switch --languages en,sk builds only the packs that are asked for.

What a page loads for the texts: source files and the built gameSix horizontal bars, the size after gzip. A page in English loads from the source files 12 files (111 kB), from the built game 2 files (88 kB). In Slovak 21 files (222 kB) against 3 files (183 kB), in Russian 21 files (238 kB) against 3 files (199 kB).English · source files111 kB12 files · 385 kB rawEnglish · built game88 kB2 files · 271 kB rawSlovak · source files222 kB21 files · 746 kB rawSlovak · built game183 kB3 files · 547 kB rawRussian · source files238 kB21 files · 900 kB rawRussian · built game199 kB3 files · 700 kB rawsource files (development mode)built gameSize after gzip -9, each file separately.The built game joins the files and shrinks them.
What the page loads for the texts: source files js/ against the built game (node tools/build.js from the tree of the game 0.124.0: files i18n.js, i18n/en.js and i18n/<language>.js). Size after gzip -9 of each file separately, 1 kB = 1,000 bytes.

The built game has in English 2 files and 88 kB after gzip, in Slovak 3 files and 183 kB, at most 199 kB (Russian). The source files have 12 and 21 files and 111 and 222 kB. So the build does not only glue: it saves 16 to 21 % of the transfer after gzip and 83 to 86 % of the files.

What I take from it

  • The size follows the number of keys times the number of languages, not the form of the file. The tree was not smaller (3.6 % bigger per key); the gain is in clarity, and in the biggest file being 201 kB today instead of 452 kB.
  • A construction in a text is a contract between the key and the language. A parameter, a plural, a gender and nesting are read by the rule of the language, not by the key.
  • The texts are loaded synchronously and once. No swapping while it runs: changing the language is a reload. The simplicity costs 12 to 21 files in development and one file per language in the build.
  • What cannot be loaded falls back to English. The fallback is in the manager key by key, so a language without one file does not crash; offline this is verified.
  • The measurement from git showed what the estimate did not see. The analysis expected a smaller tree; the commit showed a bigger one. That is why the number is taken from the commit.

Sources and notes

  • State and method: Audamir 0.124.0 (6 Nov 2026); one commit with tools appeared while writing, the texts are unchanged. The game was only read: the sizes are from git ls-tree -l and git cat-file over the states of the game in the table; the build, memory and headless Chromium ran on a copy of the tree (git archive).
  • Sizes over time (table and figure): points from git log from 18 Oct to 6 Nov; keys counted by running the files in an isolated context (audamir-055-sizes.js); gzip -9 of the command line. The headers of the files are the bytes before return { and after the end of the object. The numbers for 30 Oct agree with docs/I18N-SPLIT.md and with Texts as trees.
  • Constructions and loading: js/i18n/i18n.js (introductory comment), js/i18n/packs.js, js/i18n/boot.js, js/ui/app.js, js/ui/store.js, sw.js; examples from the catalogues and the outputs of calls of t over the catalogues of the state 0.124.0 (audamir-055-demos.js).
  • Memory and build: estimate of the heap audamir-055-memory.js (V8 in node 24); headless Chromium through CDP over the built game (audamir-055-sw-cdp.js); node tools/build.js from the state 0.124.0.
  • Not measured: memory in a browser, the loading time over the network, gzip when the packs are joined into one file after minification.

Notes

  1. Until version 0.108.0 the setting was called Gender (Not specified, Man, Woman); since version 0.108.1 of 4 November 2026 it is called Grammatical gender (Not specified, Masculine, Feminine; in Slovak Rod). ↩︎