Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate multiple select drop down #3756

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/js/jqueryPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'jquery-textcomplete';
import 'jquery-touchswipe';
import select2 from 'select2';
select2(jQuery);
import 'multiple-select';
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';
22 changes: 20 additions & 2 deletions src/js/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,32 @@ 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'],
'pt_BR': ['pt', 'en'],
'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
*/
Expand Down Expand Up @@ -238,4 +256,4 @@ i18n.addResources = function(bundle) {
i18next.addResourceBundle(lang, ns, bundle, true, true);
};

export { i18n };
export { i18n, getCurrentLocaleISO };
6 changes: 3 additions & 3 deletions src/js/tabs/onboard_logging.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion src/js/tabs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ setup.initialize = function (callback) {
}
build_opt_e.html(`<span class="buildInfoClassOptions"
title="${i18n.getMessage('initialSetupInfoBuildOptions')}${buildOptions}">
<strong>${i18n.getMessage('initialSetupInfoBuildOptionsList')}</strong></span>`);
<strong>${i18n.getMessage('initialSetupInfoBuildOptionsList')}</strong>
</span>
<div class="helpicon cf_tip" i18n_title="initialSetupInfoBuildOptionsHelp"></div>`);
} else {
build_opt_e.html(i18n.getMessage(navigator.onLine ? 'initialSetupInfoBuildOptionsEmpty' : 'initialSetupNotOnline'));
}
Expand Down
3 changes: 2 additions & 1 deletion src/tabs/presets/DetailedDialog/PresetsDetailedDialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import GUI from "../../../js/gui";
import { i18n } from "../../../js/localization";
import { i18n, getCurrentLocaleISO } from "../../../js/localization";
import PickedPreset from "../PickedPreset";
import PresetTitlePanel from "../TitlePanel/PresetTitlePanel";
import FC from "../../../js/fc";
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/tabs/presets/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "../../js/localization";
import FC from '../../js/fc';
import CONFIGURATOR from '../../js/data_storage';
import UI_PHONES from '../../js/phones_ui';
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading