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
This commit is contained in:
codebytaki 2026-04-14 17:39:55 +06:00
parent 6afc5d625a
commit 477e2b78b6
4 changed files with 18 additions and 8 deletions

View file

@ -39,6 +39,11 @@
"DAGGERHEART": { "DAGGERHEART": {
"CharacterSheet": "Character Sheet", "CharacterSheet": "Character Sheet",
"ITEM_GROUPS": {
"INVENTORY": "Inventory Items",
"CHARACTER": "Character Items",
"OTHER": "Other"
},
"ACTIONS": { "ACTIONS": {
"TYPES": { "TYPES": {
"attack": { "attack": {
@ -1942,6 +1947,9 @@
} }
} }
}, },
"ACTIVE_EFFECT": {
"NEW_EFFECT": "New Effect"
},
"EFFECTS": { "EFFECTS": {
"ApplyLocations": { "ApplyLocations": {
"attackRoll": { "attackRoll": {
@ -2623,8 +2631,10 @@
} }
}, },
"ROLLTABLES": { "ROLLTABLES": {
"DEFAULT_FORMULA_NAME": "Roll Formula",
"FIELDS": { "FIELDS": {
"formulaName": { "label": "Formula Name" } "formulaName": { "label": "Formula Name" },
"formula": { "label": "Formula Roll" }
}, },
"formula": "Formula" "formula": "Formula"
}, },

View file

@ -133,7 +133,7 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
static getDefaultObject() { static getDefaultObject() {
return { return {
name: 'New Effect', name: game.i18n.localize('DAGGERHEART.ACTIVE_EFFECT.NEW_EFFECT'),
id: foundry.utils.randomID(), id: foundry.utils.randomID(),
disabled: false, disabled: false,
img: 'icons/magic/life/heart-cross-blue.webp', img: 'icons/magic/life/heart-cross-blue.webp',

View file

@ -9,7 +9,7 @@ export default class DhRollTable extends foundry.abstract.TypeDataModel {
formulaName: new fields.StringField({ formulaName: new fields.StringField({
required: true, required: true,
nullable: false, nullable: false,
initial: 'Roll Formula', initial: () => game.i18n.localize('DAGGERHEART.ROLLTABLES.DEFAULT_FORMULA_NAME'),
label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label' label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label'
}), }),
altFormula: new fields.TypedObjectField( altFormula: new fields.TypedObjectField(
@ -17,10 +17,10 @@ export default class DhRollTable extends foundry.abstract.TypeDataModel {
name: new fields.StringField({ name: new fields.StringField({
required: true, required: true,
nullable: false, nullable: false,
initial: 'Roll Formula', initial: () => game.i18n.localize('DAGGERHEART.ROLLTABLES.DEFAULT_FORMULA_NAME'),
label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label' label: 'DAGGERHEART.ROLLTABLES.FIELDS.formulaName.label'
}), }),
formula: new FormulaField({ label: 'Formula Roll', initial: '1d20' }) formula: new FormulaField({ label: 'DAGGERHEART.ROLLTABLES.FIELDS.formula.label', initial: '1d20' })
}) })
), ),
activeAltFormula: new fields.StringField({ nullable: true, initial: null }) activeAltFormula: new fields.StringField({ nullable: true, initial: null })

View file

@ -87,10 +87,10 @@ export default class DHItem extends foundry.documents.Item {
const isInventoryItem = CONFIG.Item.dataModels[type]?.metadata?.isInventoryItem; const isInventoryItem = CONFIG.Item.dataModels[type]?.metadata?.isInventoryItem;
const group = const group =
isInventoryItem === true isInventoryItem === true
? 'Inventory Items' //TODO localize ? game.i18n.localize('DAGGERHEART.ITEM_GROUPS.INVENTORY')
: isInventoryItem === false : isInventoryItem === false
? 'Character Items' //TODO localize ? game.i18n.localize('DAGGERHEART.ITEM_GROUPS.CHARACTER')
: 'Other'; //TODO localize : game.i18n.localize('DAGGERHEART.ITEM_GROUPS.OTHER');
return { value: type, label, group }; return { value: type, label, group };
} }