Localize only the moment instance

9493d05f2cc50bf3a43e600bc9a6442033443140

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +4 -3Ignore whitespace
public/scripts/i18n.js+2 -2
@@ -1,4 +1,3 @@
1-import { moment } from '../lib.js';
21import { registerDebugFunction } from './power-user.js';
32import { updateSecretDisplay } from './secrets.js';
43
@@ -10,6 +9,8 @@ var langs;
109// eslint-disable-next-line prefer-const
1110var localeData;
1211
12+export const getCurrentLocale = () => localeFile;
13+
1314/**
1415 * An observer that will check if any new i18n elements are added to the document
1516 * @type {MutationObserver}
@@ -216,7 +217,6 @@ function addLanguagesToDropdown() {
216217}
217218
218219export async function initLocales() {
219- moment.locale(localeFile);
220220 langs = await fetch('/locales/lang.json').then(response => response.json());
221221 localeData = await getLocaleData(localeFile);
222222 applyLocale();
public/scripts/utils.js+2 -1
@@ -14,6 +14,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
1414import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
1515import { getTagsList } from './tags.js';
1616import { groups, selected_group } from './group-chats.js';
17+import { getCurrentLocale } from './i18n.js';
1718
1819/**
1920 * Pagination status string template.
@@ -838,7 +839,7 @@ export function timestampToMoment(timestamp) {
838839 }
839840
840841 const iso8601 = parseTimestamp(timestamp);
841842 const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid();
842843
843844 dateCache.set(timestamp, objMoment);
844845 return objMoment;