Skip to content

Commit

Permalink
fix: default locale language for timeline (#175)
Browse files Browse the repository at this point in the history
* fix: default locale language for timeline

* Update DOMutil.js
  • Loading branch information
yotamberk authored Nov 18, 2019
1 parent cf7bc8f commit 589e489
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import moment from './lib/module/moment';
import Hammer from './lib/module/hammer';
import keycharm from 'keycharm';

moment.locale('en')
const defaultLanguage = DOMutil.getNavigatorLanguage()
moment.locale(defaultLanguage)

const timeline = {
Core ,
Expand Down
14 changes: 13 additions & 1 deletion lib/DOMutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,16 @@ export function drawBar (x, y, width, height, className, JSONcontainer, svgConta
rect.setAttributeNS(null, "style", style);
}
}
}
}

/**
* get default language
* @returns {string}
*/
export function getNavigatorLanguage() {
if (navigator.languages && navigator.languages.length) {
return navigator.languages;
} else {
return navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en';
}
}

0 comments on commit 589e489

Please sign in to comment.