daggerheart/module/data/rollTable.mjs
codebytaki 477e2b78b6 Fix: Internationalize hardcoded UI strings (Issue #1787)
- Replace hardcoded 'Inventory Items', 'Character Items', 'Other' with i18n keys
- Internationalize 'New Effect' default name in active effects
- Fix hardcoded 'Roll Formula' and 'Formula Roll' labels in roll tables
- Add translation keys to lang/en.json for proper localization support
- Ensures all UI strings can be translated to other languages

Fixes #1787: I18n: Some UI strings still seem to be hardcoded
2026-04-14 17:39:55 +06:00

38 lines
1.5 KiB
JavaScript

import FormulaField from './fields/formulaField.mjs';
//Extra definitions for RollTable
export default class DhRollTable extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
formulaName: new fields.StringField({
required: true,
nullable: false,
initial: () => game.i18n.localize('DAGGERHEART.ROLLTABLES.DEFAULT_FORMULA_NAME'),
label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label'
}),
altFormula: new fields.TypedObjectField(
new fields.SchemaField({
name: new fields.StringField({
required: true,
nullable: false,
initial: () => game.i18n.localize('DAGGERHEART.ROLLTABLES.DEFAULT_FORMULA_NAME'),
label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label'
}),
formula: new FormulaField({ label: 'DAGGERHEART.ROLLTABLES.FIELDS.formula.label', initial: '1d20' })
})
),
activeAltFormula: new fields.StringField({ nullable: true, initial: null })
};
}
getActiveFormula(baseFormula) {
return this.activeAltFormula ? (this.altFormula[this.activeAltFormula]?.formula ?? baseFormula) : baseFormula;
}
static getDefaultFormula = () => ({
name: game.i18n.localize('Roll Formula'),
formula: '1d20'
});
}