Implement localization (en only).

This commit is contained in:
Oliver Rümpelein 2021-01-13 18:02:22 +01:00
parent 2d809c955b
commit d6ddad67cc
5 changed files with 47 additions and 16 deletions

View file

@ -175,7 +175,7 @@ export const DS4 = {
},
/**
* Define the profile info types for hanndlebars of a character
* Define the profile info types for handlebars of a character
*/
profileDTypes: {
gender: "String",
@ -188,4 +188,14 @@ export const DS4 = {
eyeColor: "String",
specialCharacteristics: "String",
},
/**
* Define localization strings for Chat Visibility
*/
chatVisibilities: {
roll: "DS4.ChatVisibilityRoll",
gmroll: "DS4.ChatVisibilityGmRoll",
blindroll: "DS4.ChatVisibilityBlindRoll",
selfroll: "DS4.ChatVisibilitySelfRoll",
},
};

View file

@ -85,6 +85,7 @@ Hooks.once("setup", function () {
"progression",
"language",
"profile",
"chatVisibilities",
];
// Exclude some from sorting where the default order matters

View file

@ -1,5 +1,7 @@
// TODO: Rename to something sane.
import { DS4 } from "../config";
/**
* Provides default values for all arguments the `CheckFactory` expects.
*/
@ -112,13 +114,15 @@ async function askGmModifier(
): Promise<GmModifierData> {
// Render model interface and return value
const usedTemplate = template ?? "systems/ds4/templates/roll/roll-options.hbs";
const usedTitle = title ?? game.i18n.localize("DS4.RollDialogDefaultTitle");
const templateData = {
cssClass: "roll-option",
title: title ?? "Roll Options",
title: usedTitle,
checkTargetValue: targetValue,
maxCritSuccess: options.maxCritSuccess ?? defaultCheckOptions.maxCritSuccess,
minCritFailure: options.minCritFailure ?? defaultCheckOptions.minCritFailure,
rollModes: rollModes,
config: DS4,
};
const renderedHtml = await renderTemplate(usedTemplate, templateData);
@ -126,17 +130,22 @@ async function askGmModifier(
const dialogPromise = new Promise<HTMLFormElement>((resolve) => {
new Dialog(
{
title: title ?? "Roll Options",
title: usedTitle,
close: () => {
// Don't do anything
},
content: renderedHtml,
buttons: {
ok: {
label: "OK",
label: game.i18n.localize("DS4.RollDialogOkButton"),
callback: (html: HTMLElement | JQuery) => {
if (!("jquery" in html)) {
throw new Error("Internal Type Error");
throw new Error(
game.i18n.format("DS4.HtmlTypeError", {
exType: "JQuery",
realType: "HTMLElement",
}),
);
} else {
const innerForm = html[0].querySelector("form");
resolve(innerForm);
@ -144,7 +153,7 @@ async function askGmModifier(
},
},
cancel: {
label: "Cancel",
label: game.i18n.localize("DS4.RollDialogCancelButton"),
callback: () => {
// Don't do anything
},
@ -160,7 +169,7 @@ async function askGmModifier(
}
function parseDialogFormData(formData: HTMLFormElement, targetValue: number): GmModifierData {
const parsedData = {
return {
checkTargetValue: parseInt(formData["ctv"]?.value) ?? targetValue,
gmModifier: parseInt(formData["gmmod"]?.value) ?? 0,
maxCritSuccess: parseInt(formData["maxcoup"]?.value) ?? defaultCheckOptions.maxCritSuccess,
@ -168,8 +177,6 @@ function parseDialogFormData(formData: HTMLFormElement, targetValue: number): Gm
useSlayingDice: false,
rollMode: formData["visibility"]?.value ?? defaultCheckOptions.rollMode,
};
console.log("Data", parsedData);
return parsedData;
}
// TODO: Remove unnecessary data step by step