Skip to content
CliprWiki

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, key clipr-lang) or the browser language.
  • <html lang>, date, number and size formats follow the language (Intl, de-DE or en-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

  1. Create web/assets/i18n/<code>.json (take the keys from en.json).
  2. Add the code to LANGS/LOCALES (lib/i18n.js) and LANGS (app/clipr/i18n.py), add mail templates to TEMPLATES.
  3. Add the catalogue to sw.js (offline cache) and raise SHELL_CACHE.
  4. Wiki: the wiki is bilingual (German, English); a third language would need LANGS there 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.