Update to iD v2.18.1

This commit is contained in:
Quincy Morgan 2020-07-20 16:12:50 -04:00
parent c9310e10a4
commit b7f022ecbe
2 changed files with 46 additions and 26 deletions

View file

@ -18292,6 +18292,21 @@
localizer.scriptNames = () => _scriptNames; 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; var _loadPromise;
localizer.ensureLoaded = () => { localizer.ensureLoaded = () => {
@ -18309,15 +18324,10 @@
_dataLocales = results[1]; _dataLocales = results[1];
}) })
.then(() => { .then(() => {
const hash = utilStringQs(window.location.hash); let requestedLocales = (_preferredLocaleCodes || [])
// list of locales preferred by the browser in priority order
if (hash.locale && _dataLocales[hash.locale]) { .concat(utilDetect().browserLocales);
// the locale can be manually set in the URL hash _localeCode = bestSupportedLocale(requestedLocales);
_localeCode = hash.locale;
} else {
// otherwise use the locale specified by the browser
_localeCode = supportedBrowserLocale();
}
return Promise.all([ return Promise.all([
// always load the English locale strings as fallbacks // always load the English locale strings as fallbacks
@ -18332,34 +18342,32 @@
.catch(err => console.error(err)); // eslint-disable-line .catch(err => console.error(err)); // eslint-disable-line
}; };
// Returns the best locale requested by the browser supported by iD, if any // Returns the best locale from `locales` supported by iD, if any
function supportedBrowserLocale() { function bestSupportedLocale(locales) {
// list of locales preferred by the browser in priority order
let browserLocales = utilDetect().browserLocales;
let supportedLocales = _dataLocales; let supportedLocales = _dataLocales;
for (let i in browserLocales) { for (let i in locales) {
let browserLocale = browserLocales[i]; let locale = locales[i];
if (browserLocale.includes('-')) { // full locale ('es-ES') 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') // 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; if (supportedLocales[langPart]) return langPart;
} else { // base locale ('es') } else { // base locale ('es')
// prefer a lower-priority full locale with this base ('es' < 'es-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 && return index > i &&
locale !== browserLocale && locale2 !== locale &&
locale.split('-')[0] === browserLocale && locale2.split('-')[0] === locale &&
supportedLocales[locale]; supportedLocales[locale2];
}); });
if (fullLocale) return fullLocale; if (fullLocale) return fullLocale;
if (supportedLocales[browserLocale]) return browserLocale; if (supportedLocales[locale]) return locale;
} }
} }
@ -114037,7 +114045,7 @@
if (sawVersion === null && matchedVersion !== null) { if (sawVersion === null && matchedVersion !== null) {
if (corePreferences('sawVersion')) { if (corePreferences('sawVersion')) {
isNewUser = false; isNewUser = false;
isNewVersion = corePreferences('sawVersion') !== currVersion; isNewVersion = corePreferences('sawVersion') !== currVersion && currVersion.indexOf('-') === -1;
} else { } else {
isNewUser = true; isNewUser = true;
isNewVersion = true; isNewVersion = true;
@ -117897,7 +117905,7 @@
let context = utilRebind({}, dispatch$1, 'on'); let context = utilRebind({}, dispatch$1, 'on');
let _deferred = new Set(); let _deferred = new Set();
context.version = '2.18.0'; context.version = '2.18.1';
context.privacyVersion = '20200407'; context.privacyVersion = '20200407';
// iD will alter the hash so cache the parameters intended to setup the session // 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) { function afterLoad(cid, callback) {
return (err, result) => { return (err, result) => {
if (err) { if (err) {
@ -118404,6 +118420,10 @@
_mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(','))); _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(',')));
} }
if (context.initialHashParams.locale) {
_mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
}
// kick off some async work // kick off some async work
_mainLocalizer.ensureLoaded(); _mainLocalizer.ensureLoaded();
_background.ensureLoaded(); _background.ensureLoaded();

View file

@ -9523,7 +9523,7 @@
}, },
"shop/craft": { "shop/craft": {
"name": "Arts & Crafts Store", "name": "Arts & Crafts Store",
"terms": "art*,paint*,frame" "terms": "art*,paint*,frame,hobby"
}, },
"shop/curtain": { "shop/curtain": {
"name": "Curtain Store", "name": "Curtain Store",