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