Internationalization
UI strings go through Paraglide JS, which compiles messages/<locale>.json into typed functions
at build time.
import * as m from '#lib/paraglide/messages.js';m.some_key();This is separate from the operator-facing multilingual config values (DESCRIPTION,
TOPBAR.TITLE, …), which are resolved at runtime by resolveI18nValue().
- Key format is
underscore_separated—menu_graph_panel, notmenu.graphPanel. - Generated code in
src/lib/paraglide/is never hand-edited, and is gitignored. - Locales are registered in
project.inlang/settings.json(baseLocale+locales). The Vite plugin regeneratessrc/lib/paraglide/on dev, build and test. - Switch language with
setLocale('ko')(alsogetLocale,locales) from#lib/paraglide/runtime.js.
npm run check does not go through Vite, so on a fresh clone #lib/paraglide/* would have no
type declarations. check therefore runs npm run i18n:compile first — the Paraglide CLI with the
same options as the Vite plugin, so keep the two in sync. prepare runs it too, so a plain npm ci
leaves the tree typecheckable.
The active locale is resolved by the strategy localStorage → preferredLanguage → baseLocale: a
saved choice wins, then the browser’s preferred language, then en.
Adding a key
Section titled “Adding a key”- Add the key to
messages/en.json, the source of truth. Add it to other locales too if you can translate it; otherwise leave them alone and they fall back to English. - Run
npm run dev(orbuild). The Vite plugin regenerates the message functions. - Use it as
m.your_new_key(). - Run
npm run i18n:missingso the translation staging files pick up the new key.
Adding a language
Section titled “Adding a language”Contributors usually do this themselves, from Fink’s Settings tab, and the locale arrives as part of their translation PR. See Translating. By hand:
- Add the locale code to
localesinproject.inlang/settings.json. - Create
messages/<locale>.json. It can hold as little as{ "$schema": "..." }; the rest falls back to English. - Run
npm run i18n:missingto generatemessages/_missing_translations_<locale>.json, listing everything still to translate.
That’s it — the MiscPanel picker reads locales and labels them via Intl.DisplayNames, so no
component edit is needed, and visitors whose browser prefers the language get it automatically. The
locale code is the only link between the locales entry and the messages/<locale>.json filename,
so keep the two identical. For a custom label, add a code → label override to localeLabel in
MiscPanel.svelte.
Translation contribution flow
Section titled “Translation contribution flow”There are two ways in, and both end as an ordinary pull request.
Fink (the main path). Fink opens project.inlang straight from
GitHub, so the repository needs no setup for it. Translators edit messages/<locale>.json in the
browser, and Fink forks the repository and opens GitHub’s PR page for them. The translator-facing
walkthrough is Translating. What reaches you:
- Only the locale files that changed, and in them only the edited messages. Fink keeps every other
line byte for byte and drops empty translations rather than writing
"". - A
project.inlang/settings.jsonchange when the contributor added a language. - Plurals already in Paraglide’s variant format, since Fink edits them natively.
Before merging one, run npm run i18n:tidy -- --base origin/main on the PR branch and push the
result; fork PRs accept maintainer pushes by default. Fink adds a message to the end of the file
whenever the contributor’s copy lacks it, and a fork that is behind main lacks every key added
since. A Russian translation can therefore arrive carrying English and Korean keys that main
already has elsewhere in the file. Git merges both copies without a conflict, and JSON.parse
silently keeps one of them. The tidy moves each key back to where main has it, so the merge
collapses the two into one.
You rarely need to do this by hand. The i18n tidy workflow runs on every PR that changes a
messages/*.json file, and again on each push to it. It runs the same tidy against main and
pushes the result to the PR branch as a commit, then comments with what changed. When there is
nothing to tidy it says nothing. When it cannot finish, the check fails and one comment on the PR,
kept up to date across pushes, says why:
- A key appears twice with different values. Someone has to pick one; the comment lists each key and its lines.
- The PR doesn’t allow edits by maintainers, so the tidy can’t be pushed. The contributor ticks the box, or runs the tidy on their branch.
To run it again yourself, comment /tidy on the PR (repository owner, members and collaborators
only), or start the workflow from the Actions tab with the PR number. Since the tidy commit lands
on the PR branch, pull before you add commits to a branch of your own.
When a PR edits the staging files instead of messages/<locale>.json (the offline flow below),
comment /apply once the translation is finished, or tick apply when starting the workflow by
hand. It runs i18n:apply on the staging files the PR changed, tidies the result and pushes one
commit, so the PR shows the real change to the locale files and CI checks it before the merge.
Those staging files are written again with what is still untranslated; other languages’ staging
files are left alone. It is never automatic, because it rewrites the file the contributor is still
editing. If an entry can’t be applied (a plural key that isn’t a plural form, an input en.json
doesn’t pass), nothing is pushed and the comment names each one: the rewrite would otherwise
replace the translator’s text with the English source.
It runs nothing from the PR itself: main’s script tidies a copy of the PR’s translation files,
and the workflow file is always the copy on main, so a change to it takes effect only once
merged.
The workflow pushes with an I18N_TIDY_TOKEN repository secret: a classic personal access token
with the public_repo scope, from an account with write access. GITHUB_TOKEN cannot push to a
fork, and a fine-grained token cannot reach a repository its owner doesn’t own, which a
contributor’s fork is not.
After merging, run npm run i18n:missing, then npm run i18n:tidy. i18n:missing gives a
language the PR just added its first staging file, which the tidy never creates. The tidy then
drops the staging entries that were just translated and deletes a staging file with nothing left
in it.
CI checks both halves on every PR: a duplicate key in the merge result fails the build, and a file the tidy would still change is flagged without failing it.
Staging files (the offline fallback). For contributors who would rather work in a text editor,
messages/<locale>.json stays untouched and the translator edits a generated staging file that
contains only the keys still needing work:
| Command | Who | What it does |
|---|---|---|
npm run i18n:check | anyone | Reports missing / stale keys per locale. Changes nothing. |
npm run i18n:missing | maintainer | Writes messages/_missing_translations_<locale>.json — the gap keys, pre-filled with the en source text. |
npm run i18n:apply | maintainer | Merges those staging files back into messages/<locale>.json (in en key order) and deletes them. |
npm run i18n:tidy | maintainer | Collapses duplicate keys, puts every file in en key order, and drops staging entries already translated. |
- A key is added to
messages/en.json→ runnpm run i18n:missingto regenerate the staging files. - A translator edits
messages/_missing_translations_ko.jsonand opens a PR. Keys they’re unsure about can be left out entirely — those keep falling back to English. - After merging the PR, run
npm run i18n:applyand commit the result.
i18n:apply skips keys not present in en.json and keys left blank, and preserves stale keys rather
than dropping them. It also skips a key whose text uses a {placeholder} that en.json doesn’t
pass, and a plain string that would replace a plural already in the locale (--force overrides
the latter). Use --dry-run to preview.
i18n:tidy never decides between two different values. A duplicate key whose copies disagree
leaves its file untouched and fails the run, and a staging entry someone has edited is kept with a
warning even when the locale already has the key. --check changes nothing and exits non-zero if
anything needs tidying. --base <ref> orders en.json like that ref’s copy instead of its own.
Plurals
Section titled “Plurals”A count needs more than {count} band(s): en splits 1 band from 2 bands, and many languages
need a different word for 1, 2–4 and 5+. Write en.json counts as plurals too, never (s). The
staging files accept two short forms, and i18n:apply expands them into Paraglide’s
variant format:
{ "eq_constraint_fit": { "=0": "No bands to fit", "one": "Fit {count} band", "other": "Fit {count} bands" }, "crosssite_search_truncated": "Showing {count} of {total, plural, one {# match} other {# matches}}."}- Whole-sentence object — one key per plural form. It counts
{count}; add"plural": "total"to count another input. - Inline fragment — ICU syntax inside the string, with
#standing for the number. Use it when only a word or two changes, or when a message has two counters: the script writes out every combination, so the translator doesn’t have to.
The forms are the locale’s
CLDR plural categories
(zero, one, two, few, many, other). other is required; in the object form *, Paraglide’s own spelling of it, is read as
other. Each staging file’s @@info
lists the forms that locale uses, and i18n:apply drops any form the locale never selects, with a
warning. An exact number such as "=0": "No bands" takes precedence over the categories, but
needs Paraglide 2.27.0 or later. Below that, i18n:apply skips the key.
A plural already in en.json appears in the staging file as the object form. Anything the short
forms can’t express, such as ordinals or gender, can be written in Paraglide’s full array form,
which passes through unchanged. The parsing lives in
scripts/i18n-plural.js.
Paraglide ignores _missing_translations_*.json — it only compiles the locales listed in
project.inlang/settings.json.
Frequency Tutorial text
Section titled “Frequency Tutorial text”The Frequency Tutorial overlay’s labels are ordinary UI
strings, one _name / _desc pair per band, keyed tutorial_freq_<band>_name and
tutorial_freq_<band>_desc, where the bands are sub_bass, bass, lower_mids, upper_mids,
presence and brilliance:
{ "tutorial_freq_sub_bass_name": "Sub Bass", "tutorial_freq_sub_bass_desc": "The Rumble, usually out of human's hearing range...", "tutorial_freq_bass_name": "Bass", "tutorial_freq_bass_desc": "Determines how 'fat' or 'thin' the sound is..."}Because they compile into the bundle, operators on a CDN or pre-built deployment cannot change them — rewording one is a source build, or a PR.