Localize only the moment instance
| @@ -9,6 +9,8 @@ var langs; | |||
| 9 | // eslint-disable-next-line prefer-const | 9 | // eslint-disable-next-line prefer-const |
| 10 | var localeData; | 10 | var localeData; |
| 11 | 11 | ||
| 12 | export const getCurrentLocale = () => localeFile; | ||
| 13 | |||
| 12 | /** | 14 | /** |
| 13 | * 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 |
| 14 | * @type {MutationObserver} | 16 | * @type {MutationObserver} |
| @@ -215,7 +217,6 @@ function addLanguagesToDropdown() { | |||
| 215 | } | 217 | } |
| 216 | 218 | ||
| 217 | export async function initLocales() { | 219 | export async function initLocales() { |
| 218 | moment.locale(localeFile); | ||
| 219 | langs = await fetch('/locales/lang.json').then(response => response.json()); | 220 | langs = await fetch('/locales/lang.json').then(response => response.json()); |
| 220 | localeData = await getLocaleData(localeFile); | 221 | localeData = await getLocaleData(localeFile); |
| 221 | applyLocale(); | 222 | applyLocale(); |
| @@ -7,6 +7,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js'; | |||
| 7 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; | 7 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; |
| 8 | import { getTagsList } from './tags.js'; | 8 | import { getTagsList } from './tags.js'; |
| 9 | import { groups, selected_group } from './group-chats.js'; | 9 | import { groups, selected_group } from './group-chats.js'; |
| 10 | import { getCurrentLocale } from './i18n.js'; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * Pagination status string template. | 13 | * Pagination status string template. |
| @@ -831,7 +832,7 @@ export function timestampToMoment(timestamp) { | |||
| 831 | } | 832 | } |
| 832 | 833 | ||
| 833 | const iso8601 = parseTimestamp(timestamp); | 834 | const iso8601 = parseTimestamp(timestamp); |
| 834 | const objMoment = iso8601 ? moment(iso8601) : moment.invalid(); | 835 | const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid(); |
| 835 | 836 | ||
| 836 | dateCache.set(timestamp, objMoment); | 837 | dateCache.set(timestamp, objMoment); |
| 837 | return objMoment; | 838 | return objMoment; |