Skip to content

feat: add project-wide i18n support#209

Open
NAO-200 wants to merge 97 commits into
devfrom
feat-155-project-33-i18n
Open

feat: add project-wide i18n support#209
NAO-200 wants to merge 97 commits into
devfrom
feat-155-project-33-i18n

Conversation

@NAO-200

@NAO-200 NAO-200 commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds UI internationalization (English + German): shared locale JSON, vue-i18n on the frontend, i18n error keys on the backend, and per-user UI language stored in the DB.

Also fixes #251 (users could override protected system settings via appSettingSet) and implements #250 (optional restriction of language selection per role).


Changes

  • utils/modules/i18n/ — EN/DE catalogs; i18n-bundles.js bundles namespaces for vue-i18n (renamed from messages.js); backend uses catalogs for logs.
  • Frontend: $t / i18n-t, resolveApiMessage, translateMaybeKey, formatLocalized* for dates
  • Backend: TranslatableError, structured { key, params } in socket responses
  • Backend English output: translateMaybeKey in backend/utils/i18n.js
  • Transform migrations: DB seed strings → i18n keys (settings, placeholders, templates, …)
  • UI language: app.locale in setting (default) + user_setting (per user); logged-in users read merged appSettings from server, with localStorage (locale) until settings load, fallback en; auth pages use browser language and clear cache when logged out; save via Preferences → appSettingSet + cache; App.vue applies locale on appSettings; helpers in locale.js + utils.js
  • Docs: docs/source/for_developers/i18n.rst with developer patterns and docs/source/for_researchers/interface_language.rst for researchers

Out of scope

Not fully done in this branch:

  • Workflows
  • Settings dashboard
  • Setup wizard (SetupWizard, components/wizard/*)
  • User rights UI (RoleManagementModal, …)
  • Some admin-only dashboards/modals
  • Assignments / Submissions cluster
  • Unify utils/modules/i18n/index.js and backend/utils/i18n.js — works as-is, duplication only in helper code

#250 — Restrict language selection

New right: frontend.preferences.disableLanguageSelection (default on Guest).

  • Hides language block in Preferences
  • Blocks saving app.locale via appSettingSet (non-admin)
  • Admins unaffected; can still set locale for users

#251 — Security: system settings override

Users could write any key to user_setting and shadow system setting values.

  • New column setting.allowUserOverride (default false; true only for allowed keys like app.locale, projects.default, …)
  • user_setting beforeCreate / beforeUpdate hooks reject protected keys
  • Admins bypass via bypassSystemSettingCheck when setting prefs for users

@NAO-200 NAO-200 self-assigned this May 18, 2026
@karimouf

Copy link
Copy Markdown
Collaborator

There were a lot of files changed, very hard to look at everything, but in general looks fine from my point of view. Don't forget to add docstrings and specify which files you said were incorrectly merged

Add allowUserOverride on setting and guard user_setting writes in model hooks so appSettingSet cannot shadow system keys unless explicitly allowed or set by an admin.
Comment thread backend/webserver/Socket.js Outdated
}

if (key) {
const englishMessage = i18n.t(key, params);

@bingobongomann bingobongomann Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this line the key is translated into an english message for the logger, but in side the logger (https://github.com/UKPLab/CARE/blob/feat-155-project-33-i18n/backend/utils/logger.js#L27) we then call (https://github.com/UKPLab/CARE/blob/feat-155-project-33-i18n/backend/utils/i18n.js#L91) resolveLogText which ´ translates the key. I think we should have a unified approach for this, not both translating before and during logging

Comment thread frontend/src/assets/locale.js Outdated
* 2. Otherwise → use the browser language (if we support it)
* 3. Otherwise → English
*
* The language is stored only in the browser, not in the database.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the users language preference should be saved in the user settings

NAO-200 added 3 commits June 22, 2026 18:26
Store the default language in setting, let users override via Preferences and user_setting, and resolve locale from merged settings on protected routes while auth pages use browser language.
… restricted users

Introduce frontend.preferences.disableLanguageSelection (default for guest), hide language in Preferences, and reject app.locale via appSettingSet on the server.
Show Default UI language as a locale select in Settings and Change user settings, and move the setting into Interface / Localization via displayName migration.
NAO-200 added 14 commits June 25, 2026 01:22
Document how to add keys, namespaces, locales, and test translations in the developer guide, and explain UI language vs template content for researchers.
Document the disableLanguageSelection user right, default Guest behavior, and how administrators manage role access.
Allow placeholder interpolation in backend English log messages and route socket error logging and callback fallbacks through resolveLogText.
Remove unused serialization helpers from TranslatableError and return the i18n key from resolveEnText when English text is missing.
Add modals.importExport locale keys, wire ExportFormatModal and
ImportFormatModal, and store format labels in utils as translation keys.
Add locale keys for configuration, tags, templates, and study screens
and bind modal titles, tooltips, and export-all button labels.
Wire grade format and merge-CSV labels in StepOptions and add shared
JSON/CSV labels to common locale files.
Wire SettingItem controls and bulk-import clear-file tooltip; use an
i18n error key for admin-only user detail socket guards.
Document keypath, tag, named and indexed slots with CARE examples
and prefer i18n-t over v-html for rich translated UI text.
@NAO-200
NAO-200 marked this pull request as ready for review July 11, 2026 22:35
NAO-200 added 3 commits July 13, 2026 05:18
…tion

Replace resolveLogText/t with a single translateMaybeKey helper, log i18n keys via SQLTransport with i18nParams, and document the anti-pattern of translating before logger.error.
Restructure the how-to flowchart with numbered sections, fix the section
link list formatting, merge migration guidance into translateMaybeKey,
and tighten wording across the chapter.
Drop migration-i18n-utils in favor of backend translateMaybeKey for down migrations and document migration usage in JSDoc.
@NAO-200
NAO-200 requested a review from bingobongomann July 13, 2026 20:43
Clarify vue-i18n catalog entry point vs locale.js (active language). Update main.js, module header, and i18n developer docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants