Add translation ids

This commit is contained in:
CRuiz
2025-01-22 13:41:18 -06:00
parent f2b667d75e
commit 73782c5389
15 changed files with 506 additions and 453 deletions
@@ -30,6 +30,7 @@ import {
type AllNumericItemKey,
type AllBooleanItemKey,
} from "./settingConstants.ts";
import { $tf } from "src/lib/src/common/i18n.ts";
export class LiveSyncSetting extends Setting {
autoWiredComponent?: TextComponent | ToggleComponent | DropdownComponent | ButtonComponent | TextAreaComponent;
@@ -86,7 +87,7 @@ export class LiveSyncSetting extends Setting {
autoWireSetting(key: AllSettingItemKey, opt?: AutoWireOption) {
const conf = getConfig(key);
if (!conf) {
// throw new Error(`No such setting item :${key}`)
// throw new Error($tf("liveSyncSetting.errorNoSuchSettingItem", { key }));
return;
}
const name = `${conf.name}${statusDisplay(conf.status)}`;
@@ -216,7 +217,15 @@ export class LiveSyncSetting extends Setting {
text.inputEl.toggleClass("sls-item-invalid-value", false);
await this.commitValue(value);
} else {
this.setTooltip(`The value should ${opt.clampMin || "~"} < value < ${opt.clampMax || "~"}`);
this.setTooltip(
$tf(
"liveSyncSetting.valueShouldBeInRange",
{
min: opt.clampMin?.toString() || "~",
max: opt.clampMax?.toString() || "~",
}
)
);
text.inputEl.toggleClass("sls-item-invalid-value", true);
lastError = true;
return false;
@@ -268,7 +277,7 @@ export class LiveSyncSetting extends Setting {
this.addButton((button) => {
this.applyButtonComponent = button;
this.watchDirtyKeys = unique([...keys, ...this.watchDirtyKeys]);
button.setButtonText(text ?? "Apply");
button.setButtonText(text ?? $tf("liveSyncSettings.btnApply"));
button.onClick(async () => {
await LiveSyncSetting.env.saveSettings(keys);
LiveSyncSetting.env.reloadAllSettings();
@@ -363,7 +372,9 @@ export class LiveSyncSetting extends Setting {
}
if (this.holdValue && this.selfKey) {
const isDirty = LiveSyncSetting.env.isDirty(this.selfKey);
const alt = isDirty ? `Original: ${LiveSyncSetting.env.initialSettings![this.selfKey]}` : "";
const alt = isDirty
? $tf("liveSyncSetting.originalValue", { value: String(LiveSyncSetting.env.initialSettings?.[this.selfKey] ?? "") })
: "";
this.controlEl.toggleClass("sls-item-dirty", isDirty);
if (!this.hasPassword) {
this.nameEl.toggleClass("sls-item-dirty-help", isDirty);