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