From 589e4894b3533d5ceffc52d6631bda4eb4a7d548 Mon Sep 17 00:00:00 2001 From: Yotam Berkowitz Date: Mon, 18 Nov 2019 21:12:21 +0200 Subject: [PATCH] fix: default locale language for timeline (#175) * fix: default locale language for timeline * Update DOMutil.js --- index.js | 3 ++- lib/DOMutil.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index bb39321daf..e53330fe2e 100644 --- a/index.js +++ b/index.js @@ -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 , diff --git a/lib/DOMutil.js b/lib/DOMutil.js index 74f8e88b18..2bc9d8e7e8 100644 --- a/lib/DOMutil.js +++ b/lib/DOMutil.js @@ -217,4 +217,16 @@ export function drawBar (x, y, width, height, className, JSONcontainer, svgConta rect.setAttributeNS(null, "style", style); } } -} \ No newline at end of file +} + +/** + * 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'; + } +}