From b7f022ecbeae92e966b7825fe97515c8a198e1dc Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Mon, 20 Jul 2020 16:12:50 -0400 Subject: [PATCH] Update to iD v2.18.1 --- vendor/assets/iD/iD.js | 70 ++++++++++++++++++----------- vendor/assets/iD/iD/locales/en.json | 2 +- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/vendor/assets/iD/iD.js b/vendor/assets/iD/iD.js index 337d13fae..72e021e61 100644 --- a/vendor/assets/iD/iD.js +++ b/vendor/assets/iD/iD.js @@ -18292,6 +18292,21 @@ localizer.scriptNames = () => _scriptNames; + // The client app may want to manually set the locale, regardless of the + // settings provided by the browser + let _preferredLocaleCodes = []; + localizer.preferredLocaleCodes = function(codes) { + if (!arguments.length) return _preferredLocaleCodes; + if (typeof codes === 'string') { + // be generous and accept delimited strings as input + _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean); + } else { + _preferredLocaleCodes = codes; + } + return localizer; + }; + + var _loadPromise; localizer.ensureLoaded = () => { @@ -18309,15 +18324,10 @@ _dataLocales = results[1]; }) .then(() => { - const hash = utilStringQs(window.location.hash); - - if (hash.locale && _dataLocales[hash.locale]) { - // the locale can be manually set in the URL hash - _localeCode = hash.locale; - } else { - // otherwise use the locale specified by the browser - _localeCode = supportedBrowserLocale(); - } + let requestedLocales = (_preferredLocaleCodes || []) + // list of locales preferred by the browser in priority order + .concat(utilDetect().browserLocales); + _localeCode = bestSupportedLocale(requestedLocales); return Promise.all([ // always load the English locale strings as fallbacks @@ -18332,34 +18342,32 @@ .catch(err => console.error(err)); // eslint-disable-line }; - // Returns the best locale requested by the browser supported by iD, if any - function supportedBrowserLocale() { - // list of locales preferred by the browser in priority order - let browserLocales = utilDetect().browserLocales; + // Returns the best locale from `locales` supported by iD, if any + function bestSupportedLocale(locales) { let supportedLocales = _dataLocales; - for (let i in browserLocales) { - let browserLocale = browserLocales[i]; - if (browserLocale.includes('-')) { // full locale ('es-ES') + for (let i in locales) { + let locale = locales[i]; + if (locale.includes('-')) { // full locale ('es-ES') - if (supportedLocales[browserLocale]) return browserLocale; + if (supportedLocales[locale]) return locale; // If full locale not supported ('es-FAKE'), fallback to the base ('es') - let langPart = browserLocale.split('-')[0]; + let langPart = locale.split('-')[0]; if (supportedLocales[langPart]) return langPart; } else { // base locale ('es') // prefer a lower-priority full locale with this base ('es' < 'es-ES') - let fullLocale = browserLocales.find((locale, index) => { + let fullLocale = locales.find((locale2, index) => { return index > i && - locale !== browserLocale && - locale.split('-')[0] === browserLocale && - supportedLocales[locale]; + locale2 !== locale && + locale2.split('-')[0] === locale && + supportedLocales[locale2]; }); if (fullLocale) return fullLocale; - if (supportedLocales[browserLocale]) return browserLocale; + if (supportedLocales[locale]) return locale; } } @@ -114037,7 +114045,7 @@ if (sawVersion === null && matchedVersion !== null) { if (corePreferences('sawVersion')) { isNewUser = false; - isNewVersion = corePreferences('sawVersion') !== currVersion; + isNewVersion = corePreferences('sawVersion') !== currVersion && currVersion.indexOf('-') === -1; } else { isNewUser = true; isNewVersion = true; @@ -117897,7 +117905,7 @@ let context = utilRebind({}, dispatch$1, 'on'); let _deferred = new Set(); - context.version = '2.18.0'; + context.version = '2.18.1'; context.privacyVersion = '20200407'; // iD will alter the hash so cache the parameters intended to setup the session @@ -117985,6 +117993,14 @@ }; + // A string or array or locale codes to prefer over the browser's settings + context.locale = function(locale) { + if (!arguments.length) return _mainLocalizer.localeCode(); + _mainLocalizer.preferredLocaleCodes(locale); + return context; + }; + + function afterLoad(cid, callback) { return (err, result) => { if (err) { @@ -118404,6 +118420,10 @@ _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(','))); } + if (context.initialHashParams.locale) { + _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale); + } + // kick off some async work _mainLocalizer.ensureLoaded(); _background.ensureLoaded(); diff --git a/vendor/assets/iD/iD/locales/en.json b/vendor/assets/iD/iD/locales/en.json index 035a67642..5f051d1da 100644 --- a/vendor/assets/iD/iD/locales/en.json +++ b/vendor/assets/iD/iD/locales/en.json @@ -9523,7 +9523,7 @@ }, "shop/craft": { "name": "Arts & Crafts Store", - "terms": "art*,paint*,frame" + "terms": "art*,paint*,frame,hobby" }, "shop/curtain": { "name": "Curtain Store", -- 2.43.2