Localize only the moment instance
| @@ -1,4 +1,3 @@ | |||
| 1 | import { moment } from '../lib.js'; | ||
| 2 | import { registerDebugFunction } from './power-user.js'; | 1 | import { registerDebugFunction } from './power-user.js'; |
| 3 | import { updateSecretDisplay } from './secrets.js'; | 2 | import { updateSecretDisplay } from './secrets.js'; |
| 4 | 3 | ||
| @@ -10,6 +9,8 @@ var langs; | |||
| 10 | // eslint-disable-next-line prefer-const | 9 | // eslint-disable-next-line prefer-const |
| 11 | var localeData; | 10 | var localeData; |
| 12 | 11 | ||
| 12 | export const getCurrentLocale = () => localeFile; | ||
| 13 | |||
| 13 | /** | 14 | /** |
| 14 | * An observer that will check if any new i18n elements are added to the document | 15 | * An observer that will check if any new i18n elements are added to the document |
| 15 | * @type {MutationObserver} | 16 | * @type {MutationObserver} |
| @@ -216,7 +217,6 @@ function addLanguagesToDropdown() { | |||
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | export async function initLocales() { | 219 | export async function initLocales() { |
| 219 | moment.locale(localeFile); | ||
| 220 | langs = await fetch('/locales/lang.json').then(response => response.json()); | 220 | langs = await fetch('/locales/lang.json').then(response => response.json()); |
| 221 | localeData = await getLocaleData(localeFile); | 221 | localeData = await getLocaleData(localeFile); |
| 222 | applyLocale(); | 222 | applyLocale(); |
| @@ -14,6 +14,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js'; | |||
| 14 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; | 14 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; |
| 15 | import { getTagsList } from './tags.js'; | 15 | import { getTagsList } from './tags.js'; |
| 16 | import { groups, selected_group } from './group-chats.js'; | 16 | import { groups, selected_group } from './group-chats.js'; |
| 17 | import { getCurrentLocale } from './i18n.js'; | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | * Pagination status string template. | 20 | * Pagination status string template. |
| @@ -838,7 +839,7 @@ export function timestampToMoment(timestamp) { | |||
| 838 | } | 839 | } |
| 839 | 840 | ||
| 840 | const iso8601 = parseTimestamp(timestamp); | 841 | const iso8601 = parseTimestamp(timestamp); |
| 841 | const objMoment = iso8601 ? moment(iso8601) : moment.invalid(); | 842 | const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid(); |
| 842 | 843 | ||
| 843 | dateCache.set(timestamp, objMoment); | 844 | dateCache.set(timestamp, objMoment); |
| 844 | return objMoment; | 845 | return objMoment; |