Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize broken table #161

Open
mcglincy opened this issue Jan 4, 2023 · 1 comment
Open

Localize broken table #161

mcglincy opened this issue Jan 4, 2023 · 1 comment

Comments

@mcglincy
Copy link
Collaborator

mcglincy commented Jan 4, 2023

Switching Broken to a roll table is nice, but is there a way for a roll table result to automatically be localized? (e.g., have keys to localizable strings, that also handle [[d4]] embedding?)

@mcglincy
Copy link
Collaborator Author

mcglincy commented Jan 4, 2023

It'd be possible to localize the result text before handing back, if the text started with a translation key token or similar.

e.g.,

const isTranslationKey = (str) => { return str?.startsWith("MB.");};
export const localizedDrawFromTable = async (actor) => { const tableDraw = await drawFromTable("morkborg.random-tables", "Broken");
 for (const tableResult of tableDraw.results) { if (tableResult.text && isTranslationKey(tableResult.text)) { tableResult.text = game.i18n.localize(tableResult.text); console.log(tableResult.text); } } return tableDraw;};

But that means roll tables manually rolled on from a compendium etc wouldn't do the translation. I guess a more fully featured module could override default Foundry's table draw?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant