From 53cac9f3d22cd5563d2e3f8299ed146d6093abe5 Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 13 Apr 2025 18:54:35 +0200 Subject: [PATCH] fix: Fix i18n infrastructure Add dev dependency fix paths and key names so that the default HTML lexer can pick them up --- i18next-parser.config.js | 3 ++- package-lock.json | 1 + package.json | 1 + public/i18n/de.json | 24 +++++++++++------------- public/i18n/en.json | 24 +++++++++++------------- public/index.html | 26 +++++++++++++------------- src/index.js | 4 ++-- 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/i18next-parser.config.js b/i18next-parser.config.js index 22af168..2009540 100644 --- a/i18next-parser.config.js +++ b/i18next-parser.config.js @@ -2,9 +2,10 @@ module.exports = { defaultNamespace: 'translation', lexers: { js: ['JsxLexer'], // we're writing jsx inside .js files + html: ['HTMLLexer'], default: ['JavascriptLexer'], }, locales: ['en', 'de'], - output: 'public/lang/$LOCALE.json', + output: 'public/i18n/$LOCALE.json', input: [ 'src/*.js', 'public/*.html', ], } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2f4e8e7..c9ebfc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@creativebulma/bulma-tooltip": "^1.2.0", "@fortawesome/fontawesome-free": "^6.7.2", "css-loader": "^7.1.2", + "i18next-parser": "^9.3.0", "sass": "^1.86.3", "sass-loader": "^16.0.5", "style-loader": "^4.0.0", diff --git a/package.json b/package.json index c573362..75255c3 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@creativebulma/bulma-tooltip": "^1.2.0", "@fortawesome/fontawesome-free": "^6.7.2", "css-loader": "^7.1.2", + "i18next-parser": "^9.3.0", "sass": "^1.86.3", "sass-loader": "^16.0.5", "style-loader": "^4.0.0", diff --git a/public/i18n/de.json b/public/i18n/de.json index 4150147..9a6c668 100644 --- a/public/i18n/de.json +++ b/public/i18n/de.json @@ -1,25 +1,23 @@ { - "back-to-home": "Zurück zur Homepage", "app-name": "Käfigrechner", - "number-of-rats": "Anzahl an Ratten", - "full-floors": "Vollebenen", + "how-many-rats-does-this-cage-fit": "Wie viele Ratten passen in den Käfig?", + "what-cage-should-i-get": "Käfiggröße rechnen", + "check-existing-cage": "Käfig prüfen", + "cage-measurements": "Käfigmaße", "width-cm": "Breite (cm)", "depth-cm": "Tiefe (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": "Vollebenen", + "number-of-rats": "Anzahl an Ratten", + "result": "Ergebnis", + "change-language": "Sprache ändern", "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-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 }}cm lang sein.", - "alt-savic-xl": "Bild des Käfigs Savic Suite Royal XL, ein Drahtkäfig mit vier Türen die erlauben die gesamte Vorderseite zu öffnen. Auf halber Höhe ist eine weitere Vollebene.", - "alt-savic-95-double": "Bild eines dekorierten Käfigs, des Savic Suite Royale 95 Double. Auf insgesamt vie Vollebenen sind Holz- und Papphäusschen, Hängematten, Futterschalen und mehr.", - "alt-tiaki": "Bild des Tiaki-Käfigs, ein Drahtkäfig mit vier Türen die erlauben die gesamte Vorderseite zu öffnen. Auf halber Höhe ist eine weitere Vollebene.", - "cage-measurements": "Käfigmaße", "cage-complies-with-all-criteria": "Der Käfig erfüllt alle Kriterien!", - "cage-for-x-rats": "Käfig für {{ num_rats }} Ratten", - "change-language": "Sprache ändern", - "result": "Ergebnis" -} \ No newline at end of file + "cage-for-x-rats": "Käfig für {{ num_rats }} Ratten" +} diff --git a/public/i18n/en.json b/public/i18n/en.json index 59bb45e..f493eec 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -1,25 +1,23 @@ { - "back-to-home": "Back to home", "app-name": "Cage Calculator", - "number-of-rats": "Number of Rats", - "full-floors": "Full floors", + "how-many-rats-does-this-cage-fit": "How many rats does this cage fit?", + "what-cage-should-i-get": "Calculate cage size", + "check-existing-cage": "Check cage", + "cage-measurements": "Cage measurements", "width-cm": "Width (cm)", "depth-cm": "Depth (cm)", "height-cm": "Height (cm)", - "full-floors-tooltip": "A full floor is each floor with a area greater than XXm², including the bottom of the cage.", + "full-floors": "Full floors", + "number-of-rats": "Number of Rats", + "result": "Result", + "change-language": "Change language", "failed-base-area": "The base area of the cage must not be below {{ MINIMUM_BASE_AREA }}m².", "failed-overall-area": "The overall area in the cage is to small.", - "failed-fall-height": "The possible fall height between floors must not be above {{ maximum_fall_height }}cm.", + "failed-fall-height": "The possible fall height between floors must not be above {{ maximum_fall_height }}cm.", "failed-floor-height": "The height between floors must be above {{ minimum_floor_height }}cm.", "failed-num-rats": "Rats must live in a group of at least three rats, pairs or lone rats are not species-appropriate.", "failed-minimum-length-long-side": "The long side of the cage must be at least {{ minimum_length_long_side }}cm long to enable running.", "failed-minimum-length-short-side": "The short side of the cage must be at least {{ minimum_length_short_side }}cm.", - "alt-savic-xl": "A picture of a wire bar cage with four doors that allow to open the full front of the cage. In the middle of the cage is a additional full floor.", - "alt-savic-95-double": "A picture of a decorated wire bar cage with four doors that allow to open the full front of the cage. Inside there are hammocks, toys and four full floors with lots of hides", - "alt-tiaki": "A picture of a decorated wire bar cage with four doors that allow to open the full front of the cage.", - "cage-measurements": "Cage measurements", "cage-complies-with-all-criteria": "This cage complies with all criteria!", - "cage-for-x-rats": "Cage for {{ num_rats }} rats", - "change-language": "Change language", - "result": "Result" -} \ No newline at end of file + "cage-for-x-rats": "Cage for {{ num_rats }} rats" +} diff --git a/public/index.html b/public/index.html index a4c83ee..2a9ce44 100644 --- a/public/index.html +++ b/public/index.html @@ -17,7 +17,7 @@ @@ -31,7 +31,7 @@ - How many rats does this cage fit? +

How many rats does this cage fit?

  • @@ -39,7 +39,7 @@ - What cage should I get? +

    What cage should I get?

  • @@ -47,7 +47,7 @@ - Check existing cage +

    Check existing cage

  • @@ -64,11 +64,11 @@
    -

    - +

    @@ -76,7 +76,7 @@

    - +

    @@ -84,7 +84,7 @@

    - +

    @@ -95,7 +95,7 @@

    + data-i18n="full-floors">Vollebenen @@ -112,7 +112,7 @@
    -
    @@ -123,7 +123,7 @@