From 00a8127aea46197bee6af323b3395add5c3453ac Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Fri, 11 Jul 2025 13:06:01 -0400 Subject: [PATCH] Convert localization from AMD to ES modules --- client/src/nls/de/locale.js | 4 ++-- client/src/nls/es/locale.js | 4 ++-- client/src/nls/fr/locale.js | 4 ++-- client/src/nls/index.js | 35 ++++++++++++++++++++++++++++++++ client/src/nls/ja/locale.js | 4 ++-- client/src/nls/locale.js | 11 +++++----- client/src/nls/zh/locale.js | 4 ++-- client/src/utils/localization.js | 2 +- 8 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 client/src/nls/index.js diff --git a/client/src/nls/de/locale.js b/client/src/nls/de/locale.js index 6ebc15a2184..adf53634228 100644 --- a/client/src/nls/de/locale.js +++ b/client/src/nls/de/locale.js @@ -1,5 +1,5 @@ /** en/main localization hash - for use with requirejs' i18n plugin */ -define({ +export default { // ----------------------------------------------------------------------------- masthead "Analyze Data": "Daten analysieren", Workflow: "Arbeitsablauf", @@ -201,4 +201,4 @@ define({ // ---------------------------------------------------------------------------- misc. MVC Tags: "Variablen", "Edit annotation": "Anmerkung bearbeiten", -}); +}; \ No newline at end of file diff --git a/client/src/nls/es/locale.js b/client/src/nls/es/locale.js index fbfaf079c89..c2b0481df10 100644 --- a/client/src/nls/es/locale.js +++ b/client/src/nls/es/locale.js @@ -1,6 +1,6 @@ /** en/main localization hash - for use with requirejs' i18n plugin */ -define({ +export default { // ----------------------------------------------------------------------------- masthead "Analyze Data": "Analizar Datos", @@ -817,4 +817,4 @@ define({ // ---------------------------------------------------------------------------- workflow_editor_tests "tool tooltip": "Mensaje de información sobre herramientas", // ---------------------------------------------------------------------------- -}); +}; \ No newline at end of file diff --git a/client/src/nls/fr/locale.js b/client/src/nls/fr/locale.js index a9e73af3d0c..4047d0d4730 100644 --- a/client/src/nls/fr/locale.js +++ b/client/src/nls/fr/locale.js @@ -1,5 +1,5 @@ /** fr localization */ -define({ +export default { // ----------------------------------------------------------------------------- masthead "Analyze Data": "Analyse de données", Workflow: "Workflow", @@ -453,4 +453,4 @@ define({ // ---------------------------------------------------------------------------- workflow_editor_tests "tool tooltip": false, // ---------------------------------------------------------------------------- -}); +}; \ No newline at end of file diff --git a/client/src/nls/index.js b/client/src/nls/index.js new file mode 100644 index 00000000000..10ef99519c3 --- /dev/null +++ b/client/src/nls/index.js @@ -0,0 +1,35 @@ +/** + * ES module locale aggregator + * This replaces the RequireJS i18n plugin functionality + * Loads all languages and returns them in the expected format + */ + +// Import root strings and supported languages +import { root, supportedLanguages } from './locale.js'; + +// Import all language files +import frLocale from './fr/locale.js'; +import esLocale from './es/locale.js'; +import jaLocale from './ja/locale.js'; +import zhLocale from './zh/locale.js'; +import deLocale from './de/locale.js'; + +// Build the locale strings object with the same structure +// that the i18n loader would have created +const localeStrings = { + __root: root, + __fr: frLocale, + __es: esLocale, + __ja: jaLocale, + __zh: zhLocale, + __de: deLocale, + // Add language codes without underscores for compatibility + fr: frLocale, + es: esLocale, + ja: jaLocale, + zh: zhLocale, + de: deLocale +}; + +// Export with the same structure that the i18n loader would have created +export default localeStrings; \ No newline at end of file diff --git a/client/src/nls/ja/locale.js b/client/src/nls/ja/locale.js index 54205bf383a..b2a41fd4ac6 100644 --- a/client/src/nls/ja/locale.js +++ b/client/src/nls/ja/locale.js @@ -1,5 +1,5 @@ /** ja localization */ -define({ +export default { // ----------------------------------------------------------------------------- masthead "Analyze Data": "データ解析", Workflow: "ワークフロー", @@ -279,4 +279,4 @@ define({ "Edit annotation": "アノテーションを編集", //false, "Your workflows": "あなたのワークフロー", -}); +}; \ No newline at end of file diff --git a/client/src/nls/locale.js b/client/src/nls/locale.js index 1990a842848..983ffda3180 100644 --- a/client/src/nls/locale.js +++ b/client/src/nls/locale.js @@ -1,6 +1,5 @@ -/** en/main localization hash - for use with requirejs' i18n plugin */ -define({ - root: { +/** en/main localization hash - converted to ES module */ +export const root = { // ----------------------------------------------------------------------------- masthead "Analyze Data": false, Workflow: false, @@ -459,9 +458,11 @@ define({ "Forgot password?": false, "Register here.": false, "Click here to reset your password.": false, - }, +}; + +export const supportedLanguages = { ja: true, fr: true, zh: true, es: true, -}); +}; diff --git a/client/src/nls/zh/locale.js b/client/src/nls/zh/locale.js index 8b6526c3171..3a80b41a9a4 100644 --- a/client/src/nls/zh/locale.js +++ b/client/src/nls/zh/locale.js @@ -1,6 +1,6 @@ /** zh localization */ /* any suggestions, please contact me: ishenweiyan@foxmail.com */ -define({ +export default { // ----------------------------------------------------------------------------- masthead "Analyze Data": "数据分析", Workflow: "工作流程", @@ -471,4 +471,4 @@ define({ ja: true, fr: true, zh: true, -}); +}; \ No newline at end of file diff --git a/client/src/utils/localization.js b/client/src/utils/localization.js index e8ceb519b6c..9988ddaab73 100644 --- a/client/src/utils/localization.js +++ b/client/src/utils/localization.js @@ -1,4 +1,4 @@ -import localeStrings from "i18n!nls/locale"; +import localeStrings from "@/nls/index.js"; /** * @param {String} strToLocalize