Internationalisation
One catalogue for interface, server and emails – German is the source language.
Clipr is bilingual: German (source language) and English. Further languages mainly need a catalogue.
Choosing the language
- Settings → General → Language: automatic (browser language), German or English. Stored in the account settings (
prefs.lang:auto|de|en). - Before signing in, the device's last used language applies (
localStorage, keyclipr-lang) or the browser language. <html lang>, date, number and size formats follow the language (Intl,de-DEoren-GB).
Catalogue
web/assets/i18n/<lang>.json is the only source of translations – for the interface and the server.
- Keys are the German texts from the code (like gettext msgids). If an entry is missing, the text stays German.
- Patterns with
{}:"Datei größer als {} MB": "File larger than {} MB". Inserted values are looked up themselves; names and other user data stay unchanged. - Named placeholders (
{n},{name}…) for texts the code composes itself:t('in {n} Tagen', { n }).
Interface
lib/i18n.js translates centrally when content is inserted into the page (MutationObserver): text nodes and the attributes title, aria-label, placeholder and alt. Views write German texts; only composed texts go through t(). Areas with data-i18n-skip, textarea, code and .mono are never touched.
Always use t() for composed texts. A text node such as ${n} Codes vorzeigen or ${source}, ${date} matches no catalogue key and stays German in the English interface. Correct: t('{n} Codes vorzeigen', { n }).
Values that are stored (for example a reason in a select list) get their own value attribute. Otherwise the translated label would be stored.
Server
app/clipr/i18n.py: a request's language comes from x-clipr-lang (set by the app), otherwise from Accept-Language. ApiError messages and message fields are translated with it.
Emails (services/mailer.py, TEMPLATES) go out in the language of the recipient account: the chosen language, for “automatic” the one last used in the app (prefs.lang_seen). Emails to addresses without an account (registration, invitations) use the language of the triggering request.
Adding a language
- Create
web/assets/i18n/<code>.json(take the keys fromen.json). - Add the code to
LANGS/LOCALES(lib/i18n.js) andLANGS(app/clipr/i18n.py), add mail templates toTEMPLATES. - Add the catalogue to
sw.js(offline cache) and raiseSHELL_CACHE. - Wiki: the wiki is bilingual (German, English); a third language would need
LANGSthere and translations of all pages.
Checking
app/tests/test_i18n.py checks catalogue consistency (placeholders), server messages and email language. For the interface, a run through all views with an English browser collecting remaining German text nodes helps.