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;
9// eslint-disable-next-line prefer-const9// eslint-disable-next-line prefer-const
10var localeData;10var localeData;
1111
12export const getCurrentLocale = () => localeFile;
13
12/**14/**
13 * An observer that will check if any new i18n elements are added to the document15 * 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}
216218
217export async function initLocales() {219export 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();
public/scripts/utils.js+2 -1
@@ -7,6 +7,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
7import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';7import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
8import { getTagsList } from './tags.js';8import { getTagsList } from './tags.js';
9import { groups, selected_group } from './group-chats.js';9import { groups, selected_group } from './group-chats.js';
10import { getCurrentLocale } from './i18n.js';
1011
11/**12/**
12 * Pagination status string template.13 * Pagination status string template.
@@ -831,7 +832,7 @@ export function timestampToMoment(timestamp) {
831 }832 }
832833
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();
835836
836 dateCache.set(timestamp, objMoment);837 dateCache.set(timestamp, objMoment);
837 return objMoment;838 return objMoment;