diff --git a/examples/simple_index.html b/examples/simple_index.html index e0c0ee61..78a8e98d 100644 --- a/examples/simple_index.html +++ b/examples/simple_index.html @@ -16,8 +16,8 @@

Nothing to see here, open a debug console in your browser to see the interes let input_value = 'Mo-Tu,Do-Fr 10:00-20:00; Samstag und Sonntag geschlossen'; // Language for the warnings (get it from the browser settings). - let locale = navigator.language.split('-')[0]; - + let locale = navigator.language; + // Create opening_hours object. let oh = new opening_hours(input_value, {}, { 'locale': locale }); diff --git a/index.js b/index.js index 1fc1ed12..1126bf49 100644 --- a/index.js +++ b/index.js @@ -101,8 +101,8 @@ export default function(value, nominatim_object, optional_conf_parm) { /* }}} */ /* Translation function {{{ */ - /* Roughly compatibly to i18next so we can replace everything by i18next include later - * sprintf support + /* Roughly compatibly to i18next so we can replace everything by i18next with + * sprintf support. */ var locale = 'en'; // Default locale if (typeof i18n === 'object') { @@ -200,7 +200,10 @@ export default function(value, nominatim_object, optional_conf_parm) { if (typeof optional_conf_parm === 'number') { oh_mode = optional_conf_parm; } else if (typeof optional_conf_parm === 'object') { - locale = optional_conf_parm['locale']; + if (typeof optional_conf_parm['locale'] === 'string') { + /* TODO: The split thing is obviously a workaround. */ + locale = optional_conf_parm['locale'].split('-')[0]; + } if (checkOptionalConfParm('mode', 'number')) { oh_mode = optional_conf_parm['mode']; }