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.40 Replies
How are you adding new consumable types?
Hooks.on('ready')
, overriding CONFIG.DND5E.consumableTypes
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 versionshttps://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 versionsGitLab
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...
I'd just add that hook (on 'setup'?), as is, with
localizeKeys
and sortKeys = ['consumableTypes']
? Easy as that? 🤔nono, you'd want something like this:
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
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.ConsumableElixirMY_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:
You could do this in your en.json
:
To make what you pasted here work, but this is not recommended.But that is what I had done. 🤔
curious
can you paste what you've got in here? or is it hosted somewhere we can see?
en.json?
and the bit of your js that deals with the hook
custom-itemTypes.mjs
:
I take back half of what I have said
😬
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...
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()
ie 'elixir' should work but not 'potionPill'
"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:
returns
'PotionTonic'
wtf
🤷
so then
potionTonic
would end up looking for DND5E.ConsumablePotionTonic
, which you have...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)
Ok, you said you tried
game.i18n.localize(...
from console and it didn't do it?
like just as a test of the localization setupInterestingly...
and just for good measure
if there's no key found it spits back what you give it
show me your module manifest in full
oh
you're gonna hate this
trailing comma
You're right.
did that do it?
Gonna test real quick, but hold on, there are commas in the system folder's en.json
it's the trailing comma that makes JSON mad
i.e. the last one shouldn't have a comma, the rest should
oh gosh darn it
yup
may I recommend #screaming-into-the-void
that was a journey lol
It works now. Thank you.
happy to help 🙂