feat: add project-wide i18n support#209
Conversation
|
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.
| } | ||
|
|
||
| if (key) { | ||
| const englishMessage = i18n.t(key, params); |
There was a problem hiding this comment.
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
| * 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. |
There was a problem hiding this comment.
the users language preference should be saved in the user settings
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.
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.
…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.
Clarify vue-i18n catalog entry point vs locale.js (active language). Update main.js, module header, and i18n developer docs.
Summary
Adds UI internationalization (English + German): shared locale JSON,
vue-i18non 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.jsbundles namespaces forvue-i18n(renamed frommessages.js); backend uses catalogs for logs.$t/i18n-t,resolveApiMessage,translateMaybeKey,formatLocalized*for datesTranslatableError, structured{ key, params }in socket responsestranslateMaybeKeyinbackend/utils/i18n.jsapp.localeinsetting(default) +user_setting(per user); logged-in users read mergedappSettingsfrom server, withlocalStorage(locale) until settings load, fallbacken; auth pages use browser language and clear cache when logged out; save via Preferences →appSettingSet+ cache;App.vueapplies locale onappSettings; helpers inlocale.js+utils.jsdocs/source/for_developers/i18n.rstwith developer patterns anddocs/source/for_researchers/interface_language.rstfor researchersOut of scope
Not fully done in this branch:
SetupWizard,components/wizard/*)RoleManagementModal, …)utils/modules/i18n/index.jsandbackend/utils/i18n.js— works as-is, duplication only in helper code#250 — Restrict language selection
New right:
frontend.preferences.disableLanguageSelection(default on Guest).app.localeviaappSettingSet(non-admin)#251 — Security: system settings override
Users could write any key to
user_settingand shadow systemsettingvalues.setting.allowUserOverride(defaultfalse;trueonly for allowed keys likeapp.locale,projects.default, …)user_settingbeforeCreate / beforeUpdate hooks reject protected keysbypassSystemSettingCheckwhen setting prefs for users