From e2437f27ccd1c7646accc75b819fff3295c7a2e2 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 8 Feb 2019 11:32:20 +0100 Subject: feat(Spell checking): Add option to automatically detect language --- src/helpers/i18n-helpers.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/helpers/i18n-helpers.js') diff --git a/src/helpers/i18n-helpers.js b/src/helpers/i18n-helpers.js index 091b86b06..84146dd8c 100644 --- a/src/helpers/i18n-helpers.js +++ b/src/helpers/i18n-helpers.js @@ -28,22 +28,33 @@ export function getLocale({ return localeStr; } -export function getSelectOptions({ locales, resetToDefaultText = '' }) { - let options = []; +export function getSelectOptions({ locales, resetToDefaultText = '', automaticDetectionText = '' }) { + const options = []; if (resetToDefaultText) { - options = [ + options.push( { value: '', label: resetToDefaultText, - }, { - value: '───', - label: '───', - disabled: true, }, - ]; + ); } + if (automaticDetectionText) { + options.push( + { + value: 'automatic', + label: automaticDetectionText, + }, + ); + } + + options.push({ + value: '───', + label: '───', + disabled: true, + }); + Object.keys(locales).sort(Intl.Collator().compare).forEach((key) => { options.push({ value: key, -- cgit v1.2.3-70-g09d2