From e2dbb7ce636852fa8e0b68ec5945bdefda0bba27 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 7 Jan 2024 19:28:18 +0100 Subject: [PATCH 1/7] Translate multiple-select to local language --- src/js/jqueryPlugins.js | 7 +++++++ src/js/localization.js | 22 ++++++++++++++++++++-- src/js/tabs/onboard_logging.js | 6 +++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index 509a23c17a..52d98f9910 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -5,5 +5,12 @@ import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); import 'multiple-select'; +// import 'multiple-select-locale-all'; +/* import 'multiple-select'; + + + + +*/ import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; diff --git a/src/js/localization.js b/src/js/localization.js index 34d24935a5..6348c7caef 100644 --- a/src/js/localization.js +++ b/src/js/localization.js @@ -11,7 +11,8 @@ const i18n = {}; window.i18n = i18n; -const languagesAvailables = ['ca', 'da', 'de', 'en', 'es', 'eu', 'fr', 'gl', 'it', 'ja', 'ko', 'nl', 'pt', 'pt_BR', 'pl', 'ru', 'uk', 'zh_CN', 'zh_TW']; +const languagesAvailables = ['ca', 'da', 'de', 'en', 'es', 'eu', 'fr', 'gl', 'it', + 'ja', 'ko', 'nl', 'pt', 'pt_BR', 'pl', 'ru', 'uk', 'zh_CN', 'zh_TW']; const languageFallback = { 'pt': ['pt_BR', 'en'], @@ -19,6 +20,23 @@ const languageFallback = { 'default': ['en'], }; +// must be aligned with languagesAvailables +const languageISOcode = ['ca-ES', 'da-DK', 'de-DE', 'en-US', 'es-ES', 'eu-ES', 'fr-FR', 'gl-ES', 'it-IT', + 'ja-JP', 'ko-KR', 'nl-NL', 'pt-PT', 'pt-BR', 'pl-PL', 'ru-RU', 'uk-UA', 'zh-CN', 'zh-TW']; + +/** + * Functions that return ISO Language Code Table from http://www.lingoes.net/en/translator/langcode.htm + * Map between languagesAvailables and languageISOcode + * Fallback to en-US + */ +function getCurrentLocaleISO() { + const isoCodeIndex = languagesAvailables.indexOf(i18next.language); + if (isoCodeIndex === -1) { + return 'en-US'; + } + return languageISOcode[isoCodeIndex]; +} + /** * Functions that depend on the i18n framework */ @@ -238,4 +256,4 @@ i18n.addResources = function(bundle) { i18next.addResourceBundle(lang, ns, bundle, true, true); }; -export { i18n }; +export { i18n, getCurrentLocaleISO }; diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 0a6f4a5281..b02aa7c5b0 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -1,4 +1,4 @@ -import { i18n } from "../localization"; +import { i18n, getCurrentLocaleISO } from "../localization"; import GUI, { TABS } from '../gui'; import { tracking } from "../Analytics"; import { mspHelper } from "../msp/MSPHelper"; @@ -272,8 +272,8 @@ onboard_logging.initialize = function (callback) { debugFieldsSelect.append(new Option(DEBUG.enableFields[i].text, i, false, enabled)); } - debugFieldsSelect.sortSelect().multipleSelect(); - + const currentLocale = getCurrentLocaleISO(); + debugFieldsSelect.sortSelect().multipleSelect({locale: currentLocale}); } else { $('.blackboxDebugFields').hide(); } From 113dd5102e0ea50fd79c76dabe17ac9ccb206ae9 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 14 Jan 2024 16:49:56 +0100 Subject: [PATCH 2/7] Include ms-locale-all --- src/js/jqueryPlugins.js | 8 +------- src/js/tabs/setup.js | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index 52d98f9910..fa65107e86 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -5,12 +5,6 @@ import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); import 'multiple-select'; -// import 'multiple-select-locale-all'; -/* import 'multiple-select'; - - - - -*/ +import 'multiple-select/dist/multiple-select-locale-all.js' import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; diff --git a/src/js/tabs/setup.js b/src/js/tabs/setup.js index 2f2c1af22b..0405b1944a 100644 --- a/src/js/tabs/setup.js +++ b/src/js/tabs/setup.js @@ -442,7 +442,9 @@ setup.initialize = function (callback) { } build_opt_e.html(` - ${i18n.getMessage('initialSetupInfoBuildOptionsList')}`); + ${i18n.getMessage('initialSetupInfoBuildOptionsList')} + +
`); } else { build_opt_e.html(i18n.getMessage(navigator.onLine ? 'initialSetupInfoBuildOptionsEmpty' : 'initialSetupNotOnline')); } From f62d304aad6ec87aadcb3ca4151ef7b2105a4226 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 14 Jan 2024 16:50:09 +0100 Subject: [PATCH 3/7] Include ms-locale-all --- src/js/jqueryPlugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index fa65107e86..e4abd7ba64 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -5,6 +5,6 @@ import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); import 'multiple-select'; -import 'multiple-select/dist/multiple-select-locale-all.js' +import 'multiple-select/dist/multiple-select-locale-all.js'; import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; From aa9f98844f891f76ae8818408d261f9e9c5a2f1a Mon Sep 17 00:00:00 2001 From: HThuren Date: Sat, 20 Jan 2024 17:22:31 +0100 Subject: [PATCH 4/7] Comment out language support for multple-select --- src/js/jqueryPlugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index e4abd7ba64..2d2fe7a84f 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -5,6 +5,6 @@ import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); import 'multiple-select'; -import 'multiple-select/dist/multiple-select-locale-all.js'; +//import 'multiple-select/dist/multiple-select-locale-all.js'; import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; From 1f4e8d54b93ab5d4f9acd6df5fbf9bb56e8f7d25 Mon Sep 17 00:00:00 2001 From: HThuren Date: Sun, 28 Jan 2024 21:44:38 +0100 Subject: [PATCH 5/7] Add locale setup to preset --- src/js/jqueryPlugins.js | 4 +++- src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js | 3 ++- src/tabs/presets/presets.js | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index 2d2fe7a84f..bf8e5c64eb 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -5,6 +5,8 @@ import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); import 'multiple-select'; -//import 'multiple-select/dist/multiple-select-locale-all.js'; +//import multipleSelect from 'multiple-select'; +//multipleSelect('destroy'); +import 'multiple-select/dist/multiple-select-locale-all.js'; import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; diff --git a/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js b/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js index 35e70ca196..9effaad056 100644 --- a/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js +++ b/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js @@ -1,5 +1,5 @@ import GUI from "../../../js/gui"; -import { i18n } from "../../../js/localization"; +import { i18n, getCurrentLocaleISO } from "../localization"; import PickedPreset from "../PickedPreset"; import PresetTitlePanel from "../TitlePanel/PresetTitlePanel"; import FC from "../../../js/fc"; @@ -174,6 +174,7 @@ export default class PresetsDetailedDialog { onUncheckAll: () => this._optionsSelectionChanged(), onOpen: () => this._optionsOpened(), hideOptgroupCheckboxes: true, + locale: getCurrentLocaleISO(), singleRadio: true, selectAll: false, styler: function (row) { diff --git a/src/tabs/presets/presets.js b/src/tabs/presets/presets.js index cfb565b3f9..38b51ba157 100644 --- a/src/tabs/presets/presets.js +++ b/src/tabs/presets/presets.js @@ -2,7 +2,7 @@ import '../../js/jqueryPlugins'; import GUI, { TABS } from '../../js/gui'; import { get as getConfig, set as setConfig } from '../../js/ConfigStorage'; import { generateFilename } from '../../js/utils/generate_filename'; -import { i18n } from '../../js/localization'; +import { i18n, getCurrentLocaleISO } from "../localization"; import FC from '../../js/fc'; import CONFIGURATOR from '../../js/data_storage'; import UI_PHONES from '../../js/phones_ui'; @@ -442,6 +442,7 @@ presets.prepareFilterSelectField = function(domSelectElement, selectOptions, min domSelectElement.multipleSelect("destroy"); domSelectElement.multipleSelect({ data: selectOptions, + locale: getCurrentLocaleISO(), showClear: true, minimumCountSelected : minimumCountSelected, placeholder: i18n.getMessage("dropDownFilterDisabled"), From 574561dba45571efdceb810261d4ceb70d04d8ee Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 29 Jan 2024 19:01:18 +0100 Subject: [PATCH 6/7] multiple-select bump to 1.7.0 --- package.json | 2 +- src/js/jqueryPlugins.js | 5 ++--- src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js | 2 +- src/tabs/presets/presets.js | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 29c2d44460..1924480d38 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "lodash.debounce": "^4.0.8", "marked": "^4.1.1", "multicast-dns": "^7.2.5", - "multiple-select": "^1.6.0", + "multiple-select": "^1.7.0", "nw-vue-devtools-prebuilt": "^0.0.10", "ol": "^8.2.0", "select2": "^4.0.13", diff --git a/src/js/jqueryPlugins.js b/src/js/jqueryPlugins.js index bf8e5c64eb..fb3ccf4d40 100644 --- a/src/js/jqueryPlugins.js +++ b/src/js/jqueryPlugins.js @@ -4,9 +4,8 @@ import 'jquery-textcomplete'; import 'jquery-touchswipe'; import select2 from 'select2'; select2(jQuery); -import 'multiple-select'; -//import multipleSelect from 'multiple-select'; -//multipleSelect('destroy'); +import multipleSelect from 'multiple-select'; +multipleSelect('init'); import 'multiple-select/dist/multiple-select-locale-all.js'; import '../../libraries/jquery.nouislider.all.min.js'; import '../../libraries/jquery.flightindicators.js'; diff --git a/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js b/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js index 9effaad056..a10ecb0b7b 100644 --- a/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js +++ b/src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js @@ -1,5 +1,5 @@ import GUI from "../../../js/gui"; -import { i18n, getCurrentLocaleISO } from "../localization"; +import { i18n, getCurrentLocaleISO } from "../../../js/localization"; import PickedPreset from "../PickedPreset"; import PresetTitlePanel from "../TitlePanel/PresetTitlePanel"; import FC from "../../../js/fc"; diff --git a/src/tabs/presets/presets.js b/src/tabs/presets/presets.js index 38b51ba157..2e243406c2 100644 --- a/src/tabs/presets/presets.js +++ b/src/tabs/presets/presets.js @@ -2,7 +2,7 @@ import '../../js/jqueryPlugins'; import GUI, { TABS } from '../../js/gui'; import { get as getConfig, set as setConfig } from '../../js/ConfigStorage'; import { generateFilename } from '../../js/utils/generate_filename'; -import { i18n, getCurrentLocaleISO } from "../localization"; +import { i18n, getCurrentLocaleISO } from "../../js/localization"; import FC from '../../js/fc'; import CONFIGURATOR from '../../js/data_storage'; import UI_PHONES from '../../js/phones_ui'; From bc9d883295a54fb2dd84d121ce387f7d85873d8c Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 29 Jan 2024 22:55:32 +0100 Subject: [PATCH 7/7] multiple-select bump to 1.7.0 --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 67c28f5135..f18eec18d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11869,10 +11869,10 @@ multipipe@^0.1.2: dependencies: duplexer2 "0.0.2" -multiple-select@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/multiple-select/-/multiple-select-1.6.0.tgz#7e2e7771f45671f014d15a662055c9ff72984a88" - integrity sha512-DnBvhl189r5NuLQa6bxsvl62ArMJVi7YDx7hjiW5ZX5agiZyiPZIzzanlsFtm4yLvR0KMwfG0TDrixJ8RNa8eg== +multiple-select@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/multiple-select/-/multiple-select-1.7.0.tgz#415e069a071098fcb367ab27b51c70f7b15103d3" + integrity sha512-KlODxbDvsg/3M+xU5pmtJb89dJzK4G3oO2miWMwAbW8UaDHfXi4DoVSRiynqwfSa0znwrT0juKEsxJ2nux7k4A== "murmur-32@^0.1.0 || ^0.2.0": version "0.2.0"