feat: Make translations use interpolation
This commit is contained in:
parent
a86e1b3935
commit
04027e26f1
@ -6,5 +6,12 @@
|
|||||||
"width-cm": "Breite (cm)",
|
"width-cm": "Breite (cm)",
|
||||||
"depth-cm": "Tiefe (cm)",
|
"depth-cm": "Tiefe (cm)",
|
||||||
"height-cm": "Höhe (cm)",
|
"height-cm": "Höhe (cm)",
|
||||||
"full-floors-tooltip": "Als Vollebenen zählen alle Ebenen die größer als 0.5m² sind, inklusive des Käfigbodens."
|
"full-floors-tooltip": "Als Vollebenen zählen alle Ebenen die größer als 0.5m² sind, inklusive des Käfigbodens.",
|
||||||
|
"failed-base-area": "Die Mindestgrundfläche des Käfigs muss {{ MINIMUM_BASE_AREA }}m² (also z.B. 100x50cm) betragen.",
|
||||||
|
"failed-overall-area": "Die Gesamtfläche im Käfig ist zu klein.",
|
||||||
|
"failed-fall-height": "Die mögliche Fallhöhe darf nicht mehr als {{ maximum_fall_height }}cm betragen.",
|
||||||
|
"failed-floor-height": "Der Mindestabstand zwischen Ebenen muss {{ minimum_floor_height }}cm betragen.",
|
||||||
|
"failed-num-rats": "Es müssen mindestens 3 Ratten zusammenleben, Paarhaltung ist nicht artgerecht.",
|
||||||
|
"failed-minimum-length-long-side": "Die lange Seite des Käfig muss mindestens {{ minimum_length_long_side }}cm lang sein um Rennen zu ermöglichen.",
|
||||||
|
"failed-minimum-length-short-side": "Die kurze Seite des Käfig muss mindestens ${(MINIMUM_LENGTH_SHORT_SIDE * 100).toFixed(0)}cm lang sein."
|
||||||
}
|
}
|
15
src/index.js
15
src/index.js
@ -34,7 +34,6 @@ function translatePageElements() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
// ...
|
|
||||||
|
|
||||||
function bindLocaleSwitcher(initialValue) {
|
function bindLocaleSwitcher(initialValue) {
|
||||||
const switcher = document.querySelector(
|
const switcher = document.querySelector(
|
||||||
@ -79,13 +78,13 @@ const FAILED_FLOOR_HEIGHT = "floor_height"
|
|||||||
class Validator {
|
class Validator {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.FAIL_CRITERIA = {
|
this.FAIL_CRITERIA = {
|
||||||
[FAILED_BASE_AREA]: i18next.t('failed-base-area'),
|
[FAILED_BASE_AREA]: i18next.t('failed-base-area', {"MINIMUM_BASE_AREA": MINIMUM_BASE_AREA}),
|
||||||
[FAILED_OVERALL_AREA]: i18next.t("failed-overall-area"),
|
[FAILED_OVERALL_AREA]: i18next.t("failed-overall-area"),
|
||||||
[FAILED_FALL_HEIGHT]: i18next.t("failed-fall-height"),
|
[FAILED_FALL_HEIGHT]: i18next.t("failed-fall-height", {"maximum_fall_height": (MAXIMUM_FALL_HEIGHT * 100).toFixed(0)}),
|
||||||
[FAILED_FLOOR_HEIGHT]: `Der Mindestabstand zwischen Ebenen muss ${(MINIMUM_FLOOR_HEIGHT * 100).toFixed(0)}cm betragen.`,
|
[FAILED_FLOOR_HEIGHT]: i18next.t("failed-floor-height", {"minimum_floor_height": (MINIMUM_FLOOR_HEIGHT * 100).toFixed(0)}),
|
||||||
[FAILED_NUM_RATS]: "Es müssen mindestens 3 Ratten zusammenleben, Paarhaltung ist nicht artgerecht.",
|
[FAILED_NUM_RATS]: i18next.t("failed-num-rats"),
|
||||||
[FAILED_MINIMUM_LENGTH_LONG_SIDE]: `Die lange Seite des Käfig muss mindestens ${(MINIMUM_LENGTH_LONG_SIDE * 100).toFixed(0)}cm lang sein um Rennen zu ermöglichen.`,
|
[FAILED_MINIMUM_LENGTH_LONG_SIDE]: i18next.t("failed-minimum-length-long-side", {"minimum_length_long_side": (MINIMUM_LENGTH_LONG_SIDE * 100).toFixed(0)}),
|
||||||
[FAILED_MINIMUM_LENGTH_SHORT_SIDE]: `Die kurze Seite des Käfig muss mindestens ${(MINIMUM_LENGTH_SHORT_SIDE * 100).toFixed(0)}cm lang sein.`,
|
[FAILED_MINIMUM_LENGTH_SHORT_SIDE]: i18next.t("failed-minimum-length-short-side", {"minimum_length_short_side": (MINIMUM_LENGTH_SHORT_SIDE * 100).toFixed(0)}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +269,7 @@ function update() {
|
|||||||
const depth = inputDepth.value
|
const depth = inputDepth.value
|
||||||
const height = inputHeight.value
|
const height = inputHeight.value
|
||||||
const dimensions = new Dimensions(width / 100, depth / 100, height / 100);
|
const dimensions = new Dimensions(width / 100, depth / 100, height / 100);
|
||||||
const validator = new Validator();
|
const validator = new Validator();
|
||||||
const failed_checks = validator.cageCheck(dimensions, ratSlider.value, fullFloorNum.value);
|
const failed_checks = validator.cageCheck(dimensions, ratSlider.value, fullFloorNum.value);
|
||||||
let resultsDiv = document.getElementById("resultsDiv");
|
let resultsDiv = document.getElementById("resultsDiv");
|
||||||
resultsDiv.innerHTML = `<strong>Ergebnis</strong>`;
|
resultsDiv.innerHTML = `<strong>Ergebnis</strong>`;
|
||||||
|
Loading…
Reference in New Issue
Block a user