new consumable types

Tried adding localization strings for some new consumable types, but keep getting this ("DND5E.Consumable[...]") no matter what. I'm 99% I have followed all guides on localization to the point. en.json in the module.json, etc etc, with all the needed strings inside.
No description
C
Calego802d ago
How are you adding new consumable types?
Z
Zhell802d ago
Hooks.on('ready'), overriding CONFIG.DND5E.consumableTypes
C
Calego802d ago
kk, looks like CONFIG.DND5E.consumableTypes has the output of game.i18n.localize cached during setup hook, So adding to that after that point you'll need to provide the already-localized versions
C
Calego802d ago
https://gitlab.com/foundrynet/dnd5e/-/blob/master/dnd5e.js#L149 This little thing does that, it runs through the CONFIG.DND5E keys provided and replaces the values with their localized versions
GitLab
dnd5e.js · master · Foundry Network / Foundry VTT 5th Edition
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
Z
Zhell802d ago
I'd just add that hook (on 'setup'?), as is, with localizeKeys and sortKeys = ['consumableTypes'] ? Easy as that? 🤔
C
Calego802d ago
nono, you'd want something like this:
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
foo: game.i18n.localize('MY_KEY')
}
})
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
foo: game.i18n.localize('MY_KEY')
}
})
the important thing is that you do the game.i18n.localize part yourself, since the 5e system believes it doesn't need to when it uses values from CONFIG.DND5E.consumableTypes
Z
Zhell802d ago
What is MY_KEY in this example? Tried CONFIG.DND5E.consumableTypes.elixir = game.i18n.localize("DND5E.ConsumableElixir") in the console as a test, but that changes its name to... well DND5E.ConsumableElixir
C
Calego802d ago
MY_KEY is a localization key you would define in your module's en.json. I wouldn't recommend using DND5E.Whatever as that implies it was added by the dnd5e package. Here's a more complete example:
// en.json
{
"my-module-id": {
"ELIXIR": "Elixir"
}
}
// en.json
{
"my-module-id": {
"ELIXIR": "Elixir"
}
}
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
elixir: game.i18n.localize('my-module-id.ELIXIR'),
somethingElse: "Something Else that Isn't Localized", // also works, just can't be translated
}
})
Hooks.on('ready', () => {
CONFIG.DND5E.consumableTypes = {
elixir: game.i18n.localize('my-module-id.ELIXIR'),
somethingElse: "Something Else that Isn't Localized", // also works, just can't be translated
}
})
// after the `ready` hook:
console.log(CONFIG.DND5E.consumableTypes.elixir); // Expected: "Elixir"
console.log(CONFIG.DND5E.consumableTypes.somethingElse); // Expected: "Something Else that Isn't Localized"
// after the `ready` hook:
console.log(CONFIG.DND5E.consumableTypes.elixir); // Expected: "Elixir"
console.log(CONFIG.DND5E.consumableTypes.somethingElse); // Expected: "Something Else that Isn't Localized"
You could do this in your en.json:
{
"DND5E.ConsumableElixir": "Elixir"
}
{
"DND5E.ConsumableElixir": "Elixir"
}
To make what you pasted here work, but this is not recommended.
Z
Zhell802d ago
But that is what I had done. 🤔
C
Calego802d ago
curious can you paste what you've got in here? or is it hosted somewhere we can see?
Z
Zhell802d ago
en.json?
C
Calego802d ago
and the bit of your js that deals with the hook
Z
Zhell802d ago
{
"DND5E.ConsumablePotionTonic": "Tonic",
"DND5E.ConsumablePotionSalve": "Salve",
"DND5E.ConsumablePotionPill": "Pill",
"DND5E.ConsumablePotionWine": "Wine",
"DND5E.ConsumablePoisonIngested": "Ingested Poison",
"DND5E.ConsumablePoisonInhaled": "Inhaled Poison",
"DND5E.ConsumablePoisonInjury": "Injury Poison",
"DND5E.ConsumablePoisonContact": "Contact Poison",
"DND5E.ConsumableDrink": "Drink",
"DND5E.ConsumableTrap": "Trap",
"DND5E.ConsumableBomb": "Bomb",
"DND5E.ConsumableElixir": "Elixir",
}
{
"DND5E.ConsumablePotionTonic": "Tonic",
"DND5E.ConsumablePotionSalve": "Salve",
"DND5E.ConsumablePotionPill": "Pill",
"DND5E.ConsumablePotionWine": "Wine",
"DND5E.ConsumablePoisonIngested": "Ingested Poison",
"DND5E.ConsumablePoisonInhaled": "Inhaled Poison",
"DND5E.ConsumablePoisonInjury": "Injury Poison",
"DND5E.ConsumablePoisonContact": "Contact Poison",
"DND5E.ConsumableDrink": "Drink",
"DND5E.ConsumableTrap": "Trap",
"DND5E.ConsumableBomb": "Bomb",
"DND5E.ConsumableElixir": "Elixir",
}
custom-itemTypes.mjs:
Hooks.on('ready', () => {
if(!game.settings.get(MODULE_NAME, SETTING_NAMES.REPLACE_CONSUMABLE_TYPES)) return;

CONFIG.DND5E.consumableTypes = {
ammo: "Ammunition",
bomb: "Bomb",
drink: "Drink",
food: "Food",
poison: "Poison",
poisonContact: "Contact Poison",
poisonIngested: "Ingested Poison",
poisonInhaled: "Inhaled Poison",
poisonInjury: "Injury Poison",
potion: "Potion",
potionTonic: "Tonic",
potionSalve: "Salve",
potionPill: "Pill",
potionWine: "Wine",
scroll: "Scroll",
trap: "Trap",
trinket: "Trinket",
elixir: "Elixir"
};
});
Hooks.on('ready', () => {
if(!game.settings.get(MODULE_NAME, SETTING_NAMES.REPLACE_CONSUMABLE_TYPES)) return;

CONFIG.DND5E.consumableTypes = {
ammo: "Ammunition",
bomb: "Bomb",
drink: "Drink",
food: "Food",
poison: "Poison",
poisonContact: "Contact Poison",
poisonIngested: "Ingested Poison",
poisonInhaled: "Inhaled Poison",
poisonInjury: "Injury Poison",
potion: "Potion",
potionTonic: "Tonic",
potionSalve: "Salve",
potionPill: "Pill",
potionWine: "Wine",
scroll: "Scroll",
trap: "Trap",
trinket: "Trinket",
elixir: "Elixir"
};
});
C
Calego802d ago
I take back half of what I have said
Z
Zhell802d ago
😬
C
Calego802d ago
https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/apps/ability-use-dialog.js#L169 Here's where the string that's displayed is being composed. Spot the problem
GitLab
module/apps/ability-use-dialog.js · master · Foundry Network / Foun...
An implementation of the Dungeons & Dragons 5th Edition game system for Foundry Virtual Tabletop (http://foundryvtt.com). This work is permitted under the Open...
C
Calego802d ago
type: game.i18n.localize(`DND5E.Consumable${item.data.consumableType.capitalize()}`),
type: game.i18n.localize(`DND5E.Consumable${item.data.consumableType.capitalize()}`),
Instead of assuming that the value desired is in CONFIG.DND5E.consumableTypes... the localization string is constructed ad-hoc out of the consumable type on the item. sigh SO, You definitely need to add these strings to the en.json with the DND5E. prefix And, since this doesn't really care about the consumableTypes value, you need to make sure your key is structured so that it's going to work with that capitalize()
Z
Zhell802d ago
ie 'elixir' should work but not 'potionPill'
C
Calego802d ago
"DND5E.ConsumablePotionTonic": "Tonic", Might need to be: "DND5E.ConsumablePotiontonic": "Tonic", capitalize apparently isn't a normal string method... so I can't tell but in-foundry try this from console:
'potionTonic'.capitalize()
'potionTonic'.capitalize()
Z
Zhell802d ago
returns 'PotionTonic'
C
Calego802d ago
wtf
Z
Zhell802d ago
🤷
No description
C
Calego802d ago
so then potionTonic would end up looking for DND5E.ConsumablePotionTonic, which you have...
Z
Zhell802d ago
Yeah and Elixir, Bomb, etc etc, they should all work (... also apparently 'ammo' doesn't work either. I didn't add that, I just kept it in because I wanted to keep it)
C
Calego802d ago
Ok, you said you tried game.i18n.localize(... from console and it didn't do it? like just as a test of the localization setup
Z
Zhell802d ago
No description
Z
Zhell802d ago
Interestingly...
No description
Z
Zhell802d ago
and just for good measure
No description
C
Calego802d ago
if there's no key found it spits back what you give it show me your module manifest in full
Z
Zhell802d ago
{
"name": "zhell-custom-stuff",
"title": "Zhell's Custom Stuff",
"description": "Personal module for replacing or adding to many things. Modular.",
"version": "3.83",
"author": "Zhell",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"packs": [
{
"name": "base-items",
"label": "Base Items",
"path": "./packs/base-items.db",
"entity": "Item",
"type": "Item"
}
],
"esmodules": [
"./setup.js",
"./scripts/custom-conditions.mjs",
"./scripts/custom-languages.mjs",
"./scripts/custom-profs.mjs",
"./scripts/custom-progression.mjs",
"./scripts/custom-recharge.mjs",
"./scripts/custom-itemTypes.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
]
}
{
"name": "zhell-custom-stuff",
"title": "Zhell's Custom Stuff",
"description": "Personal module for replacing or adding to many things. Modular.",
"version": "3.83",
"author": "Zhell",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"packs": [
{
"name": "base-items",
"label": "Base Items",
"path": "./packs/base-items.db",
"entity": "Item",
"type": "Item"
}
],
"esmodules": [
"./setup.js",
"./scripts/custom-conditions.mjs",
"./scripts/custom-languages.mjs",
"./scripts/custom-profs.mjs",
"./scripts/custom-progression.mjs",
"./scripts/custom-recharge.mjs",
"./scripts/custom-itemTypes.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "languages/en.json"
}
]
}
C
Calego802d ago
oh you're gonna hate this
"DND5E.ConsumableElixir": "Elixir",
}
"DND5E.ConsumableElixir": "Elixir",
}
trailing comma
Z
Zhell802d ago
You're right.
C
Calego802d ago
did that do it?
Z
Zhell802d ago
Gonna test real quick, but hold on, there are commas in the system folder's en.json
C
Calego802d ago
it's the trailing comma that makes JSON mad i.e. the last one shouldn't have a comma, the rest should
Z
Zhell802d ago
oh gosh darn it
C
Calego802d ago
yup may I recommend #screaming-into-the-void that was a journey lol
Z
Zhell802d ago
It works now. facepalmpicard Thank you.
C
Calego802d ago
happy to help 🙂
Want results from more Discord servers?
Add your server
More Posts
spell-compendium-5e alpha1Overriding onDropItem & onSortItemYou'd override them in your sheet class.getter & setter wrapper for settingsI'm trying to use a getter & setter pair as an interface for `game.settings.get` and `game.settings.scrollable tab contentsIt is possible, and you're firmly in the css and DOM structure side of development with this line ofJr devI'm cleaning out my bookmarks and accidentally came back to this article. Potentially useful startinHTCPackage: `hero-creation-tool`System Specific CSSI'm not 100% about this, but it is worth watching out that your solution doesn't actually end up beiadvancement-wipCommander register apitalking about permissions, im working on the registering api for the Commander, and I wanted to ask Azgaars Blurry MapHey all. I'm taking a look at my importer for Azgaar's Fantasy Map Generator and wondering how I canccjmk overlaybut for what I wanted I think I *needed* to append it there so that I can overlay the whole screencliits very very early alpha demoMonarch APIAlright, adventurous ones: I have a Beta version of Monarch with the new components API! Manifest: compacted chat cardsModules create problems to solve problems... Today's problem: "When I roll an attack, it eats the whdragdrop shenneneginsRight now, a user can drag a spell onto their character sheet. I store that in a 'spell' array and leffect mini modulesI've gotten to the point where I'm confident in releasing a slurry of tiny no-config Active Effect rdamage application hooksNew 5e Hook ideas, gimme yer thoughts: `Hooks.call('Actor5e.preDamageApplied')` args: `damageAmounthook conventionsRegarding hooks, is the convention that _all_ `pre...` hooks are executed on the machine that initiaexpand arraysIs there a way to `expandObject` except for an Array?edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on own