Skip to content

Commit

Permalink
Move locale.split('-')[0] workaround to library to keep the API stable
Browse files Browse the repository at this point in the history
As discussed in #350.
  • Loading branch information
ypid committed Nov 15, 2020
1 parent 0d413cd commit 2ff6e15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/simple_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h1>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 });

Expand Down
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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'];
}
Expand Down

0 comments on commit 2ff6e15

Please sign in to comment.