From ce469b1e2d66a5f598d316e0836ea361a4ccc61a Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Thu, 13 Aug 2020 15:08:27 +0200 Subject: Fixed setting moment.js locale to user-defined language Signed-off-by: Erik Michelson --- public/js/extra.js | 7 ++++++- public/js/locale.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'public') diff --git a/public/js/extra.js b/public/js/extra.js index 6cda6171..10c3735b 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1,6 +1,6 @@ /* eslint-env browser, jquery */ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */ -/* global moment, serverurl */ +/* global moment, serverurl, Cookies */ import Prism from 'prismjs' import hljs from 'highlight.js' @@ -31,6 +31,11 @@ require('../vendor/md-toc') var Viz = require('viz.js') const ui = getUIElements() +if (Cookies.get('locale')) { + const lang = Cookies.get('locale') + moment.locale(lang) +} + // auto update last change window.createtime = null window.lastchangetime = null diff --git a/public/js/locale.js b/public/js/locale.js index 670370d4..05c7b3e3 100644 --- a/public/js/locale.js +++ b/public/js/locale.js @@ -21,6 +21,7 @@ if (Cookies.get('locale')) { } locale.val(lang) +window.moment.locale(lang) $('select.ui-locale option[value="' + lang + '"]').attr('selected', 'selected') locale.change(function () { -- cgit v1.2.3