diff --git a/packages/kitten-scientists/source/ui/StateManagementUi.ts b/packages/kitten-scientists/source/ui/StateManagementUi.ts index c94a7aeed..2007cd861 100644 --- a/packages/kitten-scientists/source/ui/StateManagementUi.ts +++ b/packages/kitten-scientists/source/ui/StateManagementUi.ts @@ -1,8 +1,10 @@ import { isNil } from "@oliversalzburg/js-utils/nil.js"; import { formatDistanceToNow } from "date-fns/formatDistanceToNow"; +import { Locale, de, enUS, he, zhCN } from "date-fns/locale"; import { EngineState } from "../Engine.js"; import { UserScript } from "../UserScript.js"; import { Icons } from "../images/Icons.js"; +import { SettingOptions } from "../settings/Settings.js"; import { StateSettings } from "../settings/StateSettings.js"; import { cerror } from "../tools/Log.js"; import { SavegameLoader } from "../tools/SavegameLoader.js"; @@ -26,8 +28,9 @@ export type StoredState = { export class StateManagementUi extends SettingsPanel { readonly states = new Array(); readonly stateList: SettingsList; + readonly locale: Locale; - constructor(host: UserScript, settings: StateSettings) { + constructor(host: UserScript, settings: StateSettings, language: SettingOptions) { const label = host.engine.i18n("state.title"); super(host, label, settings, { settingItem: new LabelListItem(host, label, { icon: Icons.State }), @@ -38,6 +41,15 @@ export class StateManagementUi extends SettingsPanel { hasDisableAll: false, }); + this.locale = + language.selected === "zh" + ? zhCN + : language.selected === "he" + ? he + : language.selected === "de" + ? de + : enUS; + this.addChild( new SettingsList(host, { children: [ @@ -163,6 +175,7 @@ export class StateManagementUi extends SettingsPanel { this._host, `${state.label ?? unlabeled} (${formatDistanceToNow(new Date(state.timestamp), { addSuffix: true, + locale: this.locale, })})`, { onClick: () => this.loadState(state.state), title: state.timestamp }, ); diff --git a/packages/kitten-scientists/source/ui/UserInterface.ts b/packages/kitten-scientists/source/ui/UserInterface.ts index 95fadeacb..1e3b49279 100644 --- a/packages/kitten-scientists/source/ui/UserInterface.ts +++ b/packages/kitten-scientists/source/ui/UserInterface.ts @@ -56,7 +56,7 @@ export class UserInterface extends UiComponent { new TimeSettingsUi(this._host, engine.timeManager.settings), new TimeControlSettingsUi(this._host, engine.timeControlManager.settings), new LogFiltersSettingsUi(this._host, engine.settings.filters), - new StateManagementUi(this._host, engine.settings.states), + new StateManagementUi(this._host, engine.settings.states, engine.settings.language), new InternalsUi(this._host, engine.settings), ];