mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Localize only the moment instance
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
import { moment } from '../lib.js';
|
|
||||||
import { registerDebugFunction } from './power-user.js';
|
import { registerDebugFunction } from './power-user.js';
|
||||||
import { updateSecretDisplay } from './secrets.js';
|
import { updateSecretDisplay } from './secrets.js';
|
||||||
|
|
||||||
@ -10,6 +9,8 @@ var langs;
|
|||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
var localeData;
|
var localeData;
|
||||||
|
|
||||||
|
export const getCurrentLocale = () => localeFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An observer that will check if any new i18n elements are added to the document
|
* An observer that will check if any new i18n elements are added to the document
|
||||||
* @type {MutationObserver}
|
* @type {MutationObserver}
|
||||||
@ -216,7 +217,6 @@ function addLanguagesToDropdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function initLocales() {
|
export async function initLocales() {
|
||||||
moment.locale(localeFile);
|
|
||||||
langs = await fetch('/locales/lang.json').then(response => response.json());
|
langs = await fetch('/locales/lang.json').then(response => response.json());
|
||||||
localeData = await getLocaleData(localeFile);
|
localeData = await getLocaleData(localeFile);
|
||||||
applyLocale();
|
applyLocale();
|
||||||
|
@ -14,6 +14,7 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
|
|||||||
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
|
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
|
||||||
import { getTagsList } from './tags.js';
|
import { getTagsList } from './tags.js';
|
||||||
import { groups, selected_group } from './group-chats.js';
|
import { groups, selected_group } from './group-chats.js';
|
||||||
|
import { getCurrentLocale } from './i18n.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pagination status string template.
|
* Pagination status string template.
|
||||||
@ -838,7 +839,7 @@ export function timestampToMoment(timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const iso8601 = parseTimestamp(timestamp);
|
const iso8601 = parseTimestamp(timestamp);
|
||||||
const objMoment = iso8601 ? moment(iso8601) : moment.invalid();
|
const objMoment = iso8601 ? moment(iso8601).locale(getCurrentLocale()) : moment.invalid();
|
||||||
|
|
||||||
dateCache.set(timestamp, objMoment);
|
dateCache.set(timestamp, objMoment);
|
||||||
return objMoment;
|
return objMoment;
|
||||||
|
Reference in New Issue
Block a user