Localize only the moment instance

517b140911cb063c42790168c8510eab09fa6559

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

2 files changed, +4 -2Ignore whitespace
public/scripts/i18n.js+2 -1
@@ -9,6 +9,8 @@ var langs;
99// eslint-disable-next-line prefer-const
1010var localeData;
1111
12+export const getCurrentLocale = () => localeFile;
13+
1214/**
1315 * An observer that will check if any new i18n elements are added to the document
1416 * @type {MutationObserver}
@@ -215,7 +217,6 @@ function addLanguagesToDropdown() {
215217}
216218
217219export async function initLocales() {
218- moment.locale(localeFile);
219220 langs = await fetch('/locales/lang.json').then(response => response.json());
220221 localeData = await getLocaleData(localeFile);
221222 applyLocale();
public/scripts/utils.js+2 -1
@@ -7,6 +7,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
77import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
88import { getTagsList } from './tags.js';
99import { groups, selected_group } from './group-chats.js';
10+import { getCurrentLocale } from './i18n.js';
1011
1112/**
1213 * Pagination status string template.
@@ -831,7 +832,7 @@ export function timestampToMoment(timestamp) {
831832 }
832833
833834 const iso8601 = parseTimestamp(timestamp);
834835 const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid();
835836
836837 dateCache.set(timestamp, objMoment);
837838 return objMoment;