Skip to content

Commit

Permalink
Merge pull request #1039 from sharak/issue-1038
Browse files Browse the repository at this point in the history
translate +{stat} at end of trigger on move roll popup and stat tooltips
  • Loading branch information
ben authored Feb 4, 2025
2 parents 805e9c1 + e0cc4d1 commit 5734c8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next Release

- Fix an i18n issue with the translation of stats in the pre-roll dialog ([#1039](https://github.com/ben/foundry-ironsworn/pull/1039/files)) - thanks [@sharak](https://github.com/sharak)!

## 1.24.9

- Set a default icon for stellar objects, at least when changing their subtype
Expand Down
12 changes: 7 additions & 5 deletions src/module/rolls/ironsworn-roll-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ export function formatRollPlusStat(stat: string, initialCaps = false) {
* // returns "roll highest of spirit, heart, wits" for en.json
*/
export function formatRollMethod(rollMethod: DFRollMethod, stats: string[]) {
// skip if there's no choice to be made
if (stats.length === 1) {
return formatRollPlusStat(stats[0])
}
// canonical triggers have 2 stats; there's a good chance a nice string already exists, so we check for that first.
const localizedStats = stats.map((stat) =>
game.i18n.localize('IRONSWORN.' + stat.capitalize())
)

// skip if there's no choice to be made
if (localizedStats.length === 1) {
return formatRollPlusStat(localizedStats[0])
}

// canonical triggers have 2 stats; there's a good chance a nice string already exists, so we check for that first.
const methodKeyRoot = `IRONSWORN.roll method.${rollMethod}`
const possibleNiceKey = `${methodKeyRoot}.${stats.length}`
if (game.i18n.has(possibleNiceKey)) {
Expand Down
2 changes: 1 addition & 1 deletion src/module/vue/components/attr-box.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
class="block"
:class="{ [$style.box]: true, ...classes }"
:data-tooltip="formatRollPlusStat(attr, true)"
:data-tooltip="formatRollPlusStat(i18nKey, true)"
@click="click">
<label :class="$style.label">{{ $t(i18nKey) }}</label>
<div class="flexrow">
Expand Down

0 comments on commit 5734c8a

Please sign in to comment.