LiminaliaLiminalia
Technical docs: Writing scenarios: Multiple languages

Multiple languages

Open in Claude (new tab)

Languages (languages)

List the languages the game can be played in under languages in liminalia.json (the first one is the language of the original). The original scenarios stay as they are, and translations into other languages go in lang/<language>.json. In the examples below, the original is Japanese and the translation is English.

"languages": ["ja", "en"]

You can also write only the source language ("languages": ["en"] for a project written in English). The system screens then appear in that language. A project without languages is treated as a Japanese project. Projects made with lim new --lang en and with the Studio app shown in English get "languages": ["en"].

{
  "language": "en",
  "speakers": { "アカリ": "Akari" },
  "lines": {
    "start:l3f2a91c0": { "source": "「着いた……っ」", "text": "“Made it…!”", "speaker": "アカリ" },
    "start:c0a1b2c3d": { "source": "扉を調べる", "text": "Check the door", "speaker": "choice" }
  },
  "ui": { "title.start": "Begin" }
}

What gets translated: text lines (dialogue and narration), choice text, speaker names, the wording of the system screens, and the following.

KindContentsKey
Command textText written literally in parameters marked for translation in command lines (the text of @layer-text @motion-text, the text of @chat, the title of @chat-open, the message and buttons of @dialog, the heading of @text-input, the heading of @item-select, the text of @backlog-add @window-title @presence, caption of @se, title of @title-screen (and wording in ending from script format 2 or earlier), tip of choices, and t.text parameters of plugin commands), and the text in @set variable = "text"file:a…. note holds the command name (for @set, the variable’s name too, as in @set game.name)
Project settings textIn liminalia.json: title (the project’s title, shown on the title screen and as the page title); the titles, numbers and subtitles in chapters; titles and descriptions in extra (CGs, replays, music, achievements, glossary terms with their readings, aliases and descriptions, chapter select, movies, names in the character gallery, cgAuto.groups, flowchart.titles); names and descriptions in items; and in ui, chapterNames, contentWarning, contentFilter.label, help.pages, captions.sounds; the wording in endingKindsliminalia.json:t…. note holds the location (extra.cg and so on)
Project data textText in data/*.json that the data shape marks for translation (the codex’s headings, names, descriptions, body text, timeline dates and relations; the titles, prompts, names, descriptions, locked reasons and opening titles of investigation places and maps. For plugin data, translate on d.string and d.text)data/<file>:t…. note holds the file and the location (data/codex.json /entries/0/title)
  • Project data text uses the English fields (titleEn, labelEn and so on) first in English, and text with an English field isn’t listed in the English translation file. Other languages use the translation file, showing the source text when there’s no translation. After switching languages, the change shows the next time the screen opens
  • @set is translated when the right side of = is only literal text (@set game.name = "Yuika"). Values without letters (kana, kanji, Latin letters and so on) ("42"), text built with an expression ("Chapter " + n) and text added with += aren’t translated. If there’s a translation, the variable gets the translation (changing the language afterward doesn’t change the value already in the variable). Leave the translation empty for text used for comparison in conditional branches (such as @set route = "akane").
  • Parameters that hold the name of a speaker or the other party (the speaker and me of @chat, and t.name of plugin commands) are listed in speakers.
  • Values written as expressions ((…)) and the text of inline commands ({@…}) aren’t collected (inline ones are translated inside the translation of the line). Even for an expression value, it’s replaced if the same file has a translation of command text with the same original.
  • Command text and project settings text aren’t read with text syntax (ruby and so on) and are used as written.
  • Text that stays on screen (the text of @layer-text and @motion-text stay=true, the balloons of @chat and the title of @chat-open, the balloons and names of regular dialogue, the balloon of the chosen choice) is kept in the save with its translation key. Changing the language while playing shows it again in the current language right away, and loading something saved in another language also shows it in the current language (text written as an expression stays as it was when shown; an expression {= …} inside a balloon uses its value when shown again). The text of the page being read and NVL paragraphs change from the next page. Finished NVL paragraphs and text kept with {noclick} are also kept in the save with their line keys, and loading something saved in another language shows them in the current language (paragraphs in save data made with an earlier version stay in the language they were saved in). Chapter information (ctx.runtime.chapter) changes from the next playthrough started.

How to write text

  • The same syntax as text in .lim (ruby, {br}, {click}, inline commands).
  • If the original has inline commands such as {@voice …}, write them in the translation too (the syntax check warns about missing ones).
  • A line with an empty translation shows the original.

Keys and updating

The keys of lines are made from the file name, the kind and the original text (lim i18n makes them, so don’t write them by hand). Rewriting the original changes the key, and the old translation is no longer used as is. lim i18n en (and the translation screen in Studio) keeps existing translations and adds new lines with empty translations. Translations that are no longer used aren’t thrown away, and are handled as follows.

CaseWhat happens
A line with the same original exists under another key (the file was renamed, or the line was moved to another file)The translation carries over as is
The same file has a translation of a close original (the original was slightly rewritten)The translation stays empty, and previous holds the old original and translation. The translation screen in Studio shows it as “Earlier translation,” and clicking “Use” puts it into the translation field
NeitherKept in stale (if you change the original back, it returns to that line; delete it if you don’t need it)

Only lines that are no longer used and have an empty translation are removed. When you rename a scenario in Studio, the translation keys are rewritten too.

The game uses, for every scenario, the translation of the last installed pack (in pack order) that has one for that language (packs/<id>/lang/<language>.json), or the main one if none does. So lim i18n (and the translation screen in Studio) and the syntax check count translations used only by pack scripts as used: they aren’t moved to stale or reported as unused-translation. Lines of a pack with no translation for that language show with the main translation, so lim i18n lists them in the main translation and the syntax check counts them as untranslated. A pack’s translation is checked against the main scripts with that pack laid over them (a script with the same name is the pack’s), and the lines of packs that show with it when installed together (packs without that language, and earlier packs with it) count as untranslated too. Scripts of earlier packs that the pack replaces with a script of the same name never show with its translation, so they aren’t counted (only lines that show in some combination of packs count).

Lines with a fixed line ID: a line with #line:ID at the end (chapter 2) uses the key file:l@ID (file:c@ID for choices), which doesn’t depend on the original.

"start:l@3f2a91c0": { "source": "「おはよう、今日は早いのね!」", "text": "“Morning. You're early.”", "translatedFrom": "「おはよう、今日は早いのね」", "speaker": "アカリ" }
  • Rewriting the original doesn’t change the key, and the translation keeps being used. lim i18n keeps the original at the time of translation in translatedFrom (it’s removed if you change the original back). The syntax check reports their number with outdated-translation, and lim i18n <language> --export xliff --changed exports only the ones to translate again. Translating them again and importing removes translatedFrom.
  • When a line is moved to another file, the translation carries over too if the ID is the same and the original is close.
  • lim i18n --stamp-ids gives IDs to dialogue, narration and choices without one, and moves the keys in the translation files of every language to ID keys (when two or more lines with the same original shared one translation, they’re split into per-line keys, and if there were per-scene translations, the translation for that line’s scene is copied). The keys of the locked voice numbers (voice-lock.json) are moved too, and the numbers are used as they are. With a language, the translation file for that language is updated right after.

Translating by scene

The same original in the same file (short lines such as 「はい」, “yes,” or 「……」) uses one translation. To translate it differently by scene, write contexts. For items whose original appears in two or more scenes (labels), lim i18n lists the names of those scenes with empty translations. How the key is made doesn’t change.

"start:l3f2a91c0": { "source": "「はい」", "text": "“Yes.”", "speaker": "アカリ", "contexts": { "shop": "“Sure.”", "rooftop": "" } }
  • The scene is the nearest label before that line. Lines before the first label and lines inside @define have no scene and use text.
  • If a scene’s translation is empty, text is used. It works for text lines, choice text and command text.
  • In tables and XLIFF, they follow right after the item, in rows of key#scene (they aren’t counted in estimates of the amount to translate).
  • When you rename a label in Studio, the scene names of that file’s items change too. Even if a scene disappears from the scenario, the ones with translations written are kept.

System screen wording: Japanese and English are built in. Other languages are based on English and overridden with ui keys (title.start, menu.save and so on; the paths in the table in strings.ts of the default system screens). The screens of the standard commands (codex, investigation, map choice, chapter end) take their wording from the same table (codex.title, investigate.finish, mapChoice.go, chapter.end and so on). The keys for each screen are in the table in screens.md.

  • For languages other than Japanese and English, lim i18n (and the translation screen in Studio) lists every key that can be overridden, with the English original ("title.start": { "source": "New Game", "text": "" }). Keys with an empty translation show English. You can also write only the translation as a string ("title.start": "Nouvelle partie"; the next lim i18n turns it into the form with the original).
  • Keys whose English changed when the engine was updated keep using the translation, and the English at the time of translation is kept in translatedFrom (they can be exported with --changed).
  • In tables and XLIFF they’re listed in rows of ui:key, with English as the original. Keys not in the English table (ones the project added and so on) are left as written.

Handing off translations (tables and XLIFF)

lim i18n <language> --export csv|xliff --out file exports, and --import file imports the file with the translations filled in (“Export” and “Import” on the translation screen in Studio do the same).

  • The columns of the table are key kind (line, choice, command, setting, speaker, ui) speaker source translation previous_source previous_translation context. The context column and note in XLIFF hold the scene, the position (file and line), the text lines before and after, and a length guide (the number of characters shown in the original; for system screen wording, the number of characters in English). --lang en writes these in English.
  • In XLIFF, the syntax of text lines and choices becomes inline elements that translation tools don’t break: {br} {click} {noclick} become <x/>, {r …} {= …} {@…} {img …} become <ph> with their contents, and syntax that encloses text ({b …} {c …} {size …} and so on) becomes <g>. They’re turned back into .lim syntax on import. Enclosures that exist only in the translation are exported with <bpt> and <ept>.
  • --untranslated exports only items without a translation, and --changed only items whose original changed after translation (those with previous and those with translatedFrom). With both, items that match either.
  • On import, items are looked up by key, and the following aren’t written. lim i18n shows the reason and the position (the row in the table, the line in the XLIFF, the character in the translation).
    • Lines whose original differs from the current scenario (the script changed after exporting). The keys are listed.
    • For text lines and choices, translations that can’t be read as .lim text (an unclosed { and so on), and <g> or <x/> not in the original.
    • Translations missing an inline command from the original ({@voice …} and so on) are written, and reported.

The language being played

  • Chosen with “Language” in the Settings screen (and remembered). If none has been chosen, the one matching the browser’s language, or the language of the original.
  • When changed while playing, the system screens change right away and the text from the next page.

Fonts and text sizes by language

In ui.languages, write the look to layer on for each language (“Text per language” in Studio’s Game settings). The one for the language being played is layered onto ui, replacing only what’s written for each item (if you write only text.size, the other text settings stay as they are). fonts are added. You can write one for the original language too.

"ui": {
  "text": { "font": "\"Hiragino Mincho ProN\", serif", "size": 26 },
  "languages": {
    "en": { "fonts": [{ "family": "Latin", "file": "fonts/latin.woff2" }], "text": { "font": "Latin, serif", "size": 22, "lineHeight": 1.5 }, "choice": { "size": 20 } }
  }
}
  • You can write fonts, text, message, name, glyph, choice, chat, system and ending (each with the same shape as the same item in ui). Other items are a syntax check error.
  • Changing the language while playing changes them right away. Font files are included in the check that assets exist.

Assets by language

  • Put images with text in them, voices, video subtitles and so on under assets/<kind>/@<language>/, at the same path as the original (assets/bgimage/@en/title.png is assets/bgimage/title.png when playing in English). If there isn’t one, the original asset is used.
  • When the language changes while playing, they change from the next thing shown. The asset list in Studio shows how the original asset is used.

The state (variables, read status, saves) is shared regardless of language. Per-speaker handling (voice volume, lip sync) looks at the speaker name of the original. Display names ({name …} and @name in chapter 2) written as plain text are listed in speakers and translated like speaker names.