Localize only the moment instance

9493d05f2cc50bf3a43e600bc9a6442033443140

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

2 files changed, +4 -3Showing whitespace changes
public/scripts/i18n.js+2 -2
@@ -1,4 +1,3 @@
1import { moment } from '../lib.js';
2import { registerDebugFunction } from './power-user.js';1import { registerDebugFunction } from './power-user.js';
3import { updateSecretDisplay } from './secrets.js';2import { updateSecretDisplay } from './secrets.js';
43
@@ -10,6 +9,8 @@ var langs;
10// eslint-disable-next-line prefer-const9// eslint-disable-next-line prefer-const
11var localeData;10var localeData;
1211
12export const getCurrentLocale = () => localeFile;
13
13/**14/**
14 * 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
15 * @type {MutationObserver}16 * @type {MutationObserver}
@@ -216,7 +217,6 @@ function addLanguagesToDropdown() {
216}217}
217218
218export async function initLocales() {219export async function initLocales() {
219 moment.locale(localeFile);
220 langs = await fetch('/locales/lang.json').then(response => response.json());220 langs = await fetch('/locales/lang.json').then(response => response.json());
221 localeData = await getLocaleData(localeFile);221 localeData = await getLocaleData(localeFile);
222 applyLocale();222 applyLocale();
public/scripts/utils.js+2 -1
@@ -14,6 +14,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
14import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';14import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
15import { getTagsList } from './tags.js';15import { getTagsList } from './tags.js';
16import { groups, selected_group } from './group-chats.js';16import { groups, selected_group } from './group-chats.js';
17import { getCurrentLocale } from './i18n.js';
1718
18/**19/**
19 * Pagination status string template.20 * Pagination status string template.
@@ -838,7 +839,7 @@ export function timestampToMoment(timestamp) {
838 }839 }
839840
840 const iso8601 = parseTimestamp(timestamp);841 const iso8601 = parseTimestamp(timestamp);
841 const objMoment = iso8601 ? moment(iso8601) : moment.invalid();842 const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid();
842843
843 dateCache.set(timestamp, objMoment);844 dateCache.set(timestamp, objMoment);
844 return objMoment;845 return objMoment;