Skip to content

Add an informal German locale variant (de-x-informal, "du") - #528

Open
atcen wants to merge 3 commits into
sleede:devfrom
atcen:feature/german-informal-locale
Open

atcen wants to merge 3 commits into
sleede:devfrom
atcen:feature/german-informal-locale

Conversation

@atcen

@atcen atcen commented Nov 21, 2026 •

Copy link
Copy Markdown

Motivation

Many German FabLabs and makerspaces address their members informally ("du"), while Fab-manager's German translation addresses them formally ("Sie"). The current de files are also a mix of both (eg. app.public.de.yml has ~60 formal strings and a few informal ones, sometimes inside the same screen).

Crowdin only has one German target language, so there is currently no way to offer both. This PR proposes an informal German locale variant, de-x-informal, next to the existing formal de, designed so that it only needs to contain the strings that actually differ.

CONTRIBUTING.md asks to discuss larger changes first: this PR is meant as a concrete proposal, and I'm happy to change the approach (locale code, file layout, Crowdin setup…) to whatever suits you best.

Design

Locale code: de-x-informal

  • It is a valid BCP 47 tag (private use subtag), so it is safe in <html lang>, RSS <language>, Intl.*, etc.
  • Rails I18n fallbacks compute its chain as de-x-informal → de-x → de (then the default locale chain as before), so any string missing from the informal files falls back to the formal German, key by key, without any extra configuration.
  • I checked the JS libraries that receive APP_LOCALE (with the versions from yarn.lock):
    • messageformat 1.0.2 (angular-translate interpolation) strips subtags until it finds plural rules → uses de;
    • i18next 21.6.13 resolves ['de-x-informal', 'de', 'en'] (it explicitly ignores the x subtag);
    • intl-messageformat 9.11.4 / Intl.PluralRules resolve it to de.
  • MOMENT_LOCALE, SUMMERNOTE_LOCALE, ANGULAR_LOCALE, FULLCALENDAR_LOCALE and INTL_LOCALE are independent settings: they should simply be set as for the formal German (documented).

Front-end translations (API::TranslationsController)

The front-end loads whole subtrees (I18n.t('app.public')). I18n fallbacks work key by key: when a locale contains only part of a subtree, I18n.t returns that partial subtree and ignores the fallbacks, so the partial informal files would hide all the other strings.

The new TranslationsService.lookup deep-merges the subtree of every available locale of the fallback chain (least specific first, so the most specific wins; nil values don't override). The controller uses it, and keeps the previous I18n.t call as a fallback, so the behaviour of the existing locales is unchanged (when only one locale of the chain has the subtree, nothing is merged). There is no server-side caching of the translations today; the merge is only done when two locales of the chain actually contain the requested subtree, and AngularJS caches the loaded parts on the client side.

Back-end (mails, PDF, Devise messages, …)

Single-key lookups (I18n.t, t in views/mailers, Devise) already go through the fallbacks chain, so nothing else is needed. Currency formatting (CURRENCY_LOCALE = RAILS_LOCALE) falls back to rails.de.yml as well.

Other changes

  • config/initializers/locale.rb: whitelist de-x-informal.
  • crowdin.yml: map the Crowdin language code de-informal to de-x-informal (languages_mapping / two_letters_code) for every file, so that exports land in eg. config/locales/app.public.de-x-informal.yml. The code de-informal is only my suggestion: please adjust it to the code of the language you create in Crowdin.
  • Starter files app.public.de-x-informal.yml, devise.de-x-informal.yml and mails.de-x-informal.yml with a few informal strings, so the mechanism can be tried right away. Crowdin can take over from there.
  • LocaliseLib.zxcvbnDictionnaries now switches on the language part of APP_LOCALE (so de-x-informal, and also eg. es-MX, get their dictionary).
  • Docs in doc/environment.md (also added the missing de* values to the RAILS_LOCALE list and fixed en-AU-CA → en-AU, en-CA), and a CHANGELOG entry.

How to enable

RAILS_LOCALE=de-x-informal
APP_LOCALE=de-x-informal
MOMENT_LOCALE=de
SUMMERNOTE_LOCALE=de-DE
ANGULAR_LOCALE=de-de
FULLCALENDAR_LOCALE=de
INTL_LOCALE=de-DE

Request: add the language in Crowdin 🙏

Could you please create the matching language in the Crowdin project "fab-manager"? Suggestion:

  • Settings → Languages → Custom languages → Add

    • Name: German, informal (or German (du))
    • Dialect of: German
    • Code / two letters code: de-informal (or directly de-x-informal, in which case the languages_mapping in crowdin.yml can be removed). Please tell me which code you chose and I'll update the mapping.
  • Export of untranslated strings: by default, Crowdin fills untranslated strings with the English source, which would defeat the fallback to the formal German. The informal files should only contain the strings that were actually translated. Options I can see:

    1. enable Skip untranslated strings for the export (the files' root key must then be de-x-informal:). However, this is a project-wide setting, and the other languages rely on the English placeholders (their fallback chain doesn't include en in production), so it might need a separate file group or a per-language setting.
    2. alternatively, pre-translate German, informal from the formal German (TM pre-translation), so the exported files are complete and translators only have to fix the strings that use "Sie". Simpler on the Crowdin side, but corrections to the formal strings would no longer be propagated automatically.

    You know your Crowdin setup much better than I do, so I'd be glad to follow your preference.

I'm happy to help translate/review the informal strings (and to review the formal ones for consistency) once the language exists in Crowdin.

Tests

  • test/services/translations_service_test.rb: fallback chain, single keys falling back to de, deep merge of subtrees, nil values, leaf keys, missing keys, and the real informal files (frontend subtree + Devise message).
  • test/integration/translations_test.rb: GET /api/translations/de-x-informal/app.public returns the informal overrides merged with the formal German, plus a leaf lookup and the unchanged behaviour for de.

What I ran locally (Ruby 3.2.2 container, PostgreSQL 13, Redis 6; no Elasticsearch):

  • rails test test/services/translations_service_test.rb test/integration/translations_test.rb: 11 tests, 23 assertions, 0 failures. As a sanity check, the integration test fails with the previous controller code.
  • rails test test/mailers test/integration/rss: 2 tests, 0 failures.
  • rubocop on the changed Ruby files: no offenses.
  • rails runner with RAILS_LOCALE=de-x-informal: I18n.default_locale is de, the fallbacks chain is de-x-informal → de-x → de, the merged app.public has exactly the same keys as de, a mail subject uses the informal string while a sibling falls back to the formal one, and number_to_currency gives 12,50 €.
  • The JS library checks above were run with Node against the exact versions from yarn.lock.

I did not run the full test suite (it needs Elasticsearch), nor the Jest/ESLint suites (the frontend change is a one-line switch on Fablab.locale.split('-')[0]), nor did I try it in a browser.

Known limitation / open question

Jobs that are not enqueued from a request (eg. scheduled reminders from sidekiq-scheduler) run with I18n.default_locale, which is only the language part of RAILS_LOCALE (de). Their e-mails therefore use the formal address. This is the same pre-existing behaviour as for the regional variants (eg. de-CH number formats, which is why invoices use CURRENCY_LOCALE), so I left it out of this PR; I could address it in a follow-up (eg. by making the jobs default to RAILS_LOCALE) if you think it's worth it.

atcen and others added 3 commits November 21, 2026 16:55
I18n fallbacks work key by key: when a locale only contains part of a
subtree, I18n.t('app.public') returns that partial subtree and ignores
the fallback locales. Deep-merge the subtrees found along the fallback
chain, so that a locale variant only needs to contain the strings that
differ from its parent locale.

When only one locale of the chain contains the subtree, nothing is
merged and the response is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address the users with "du" instead of "Sie". The locale files only
contain the strings that differ from the formal German (de); every
other string falls back to "de".

Map the Crowdin language to de-x-informal, add a few informal strings
as a starting point, and select the zxcvbn dictionary from the
language part of APP_LOCALE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant