From d546124359547b77a34b7269ccf6a94caeeebac1 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Wed, 7 Oct 2026 12:51:02 +0200 Subject: [PATCH] Add i18n dictionary and dynamic UI translations --- Dockerfile | 1 + i18n.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++ index.html | 56 +++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 i18n.js diff --git a/Dockerfile b/Dockerfile index 5c6da0a..ac0d8b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ COPY ash.css /usr/share/nginx/html/ash.css COPY gruvbox.css /usr/share/nginx/html/gruvbox.css COPY nord.css /usr/share/nginx/html/nord.css COPY config.js /usr/share/nginx/html/config.js +COPY i18n.js /usr/share/nginx/html/i18n.js COPY index.html /usr/share/nginx/html/index.html COPY noise.png /usr/share/nginx/html/noise.png EXPOSE 58881 diff --git a/i18n.js b/i18n.js new file mode 100644 index 0000000..d737b93 --- /dev/null +++ b/i18n.js @@ -0,0 +1,49 @@ +/* Internationalization dictionary + * + * Each key maps to an array of translations indexed by language code. + * To add a new language, add an entry with the language code as the key + * and translations for each existing key. + * + * Example: + * TRANSLATIONS.title = { de: 'Titel', en: 'Title' }; + * + * The current language is taken from window.CONFIG.language. + */ + +window.TRANSLATIONS = { + 'Aufgang': { de: 'Aufgang', en: 'Sunrise' }, + 'Untergang': { de: 'Untergang', en: 'Sunset' }, + 'Zenit Sonne': { de: 'Zenit Sonne', en: 'Sun Zenith' }, + 'Mondphase': { de: 'Mondphase', en: 'Moon Phase' }, + 'Mond auf': { de: 'Mond auf', en: 'Moonrise' }, + 'Mond unter': { de: 'Mond unter', en: 'Moonset' }, + + 'heute': { de: 'heute', en: 'today' }, + 'morgen': { de: 'morgen', en: 'tomorrow' }, + + 'Neumond': { de: 'Neumond', en: 'New Moon' }, + 'Zunehm. Sichel': { de: 'Zunehm. Sichel', en: 'Waxing Crescent' }, + 'Erstes Viertel': { de: 'Erstes Viertel', en: 'First Quarter' }, + 'Zunehm. Gibbous': { de: 'Zunehm. Gibbous', en: 'Waxing Gibbous' }, + 'Vollmond': { de: 'Vollmond', en: 'Full Moon' }, + 'Abnehm. Gibbous': { de: 'Abnehm. Gibbous', en: 'Waning Gibbous' }, + 'Letztes Viertel': { de: 'Letztes Viertel', en: 'Last Quarter' }, + 'Abnehm. Sichel': { de: 'Abnehm. Sichel', en: 'Waning Crescent' }, + + 'Mo.': { de: 'Mo.', en: 'Mo.' }, + 'Di.': { de: 'Di.', en: 'Tu.' }, + 'Mi.': { de: 'Mi.', en: 'We.' }, + 'Do.': { de: 'Do.', en: 'Th.' }, + 'Fr.': { de: 'Fr.', en: 'Fr.' }, + 'Sa.': { de: 'Sa.', en: 'Sa.' }, + 'So.': { de: 'So.', en: 'Su.' } +}; + +window.getTranslation = function(key) { + var lang = (window.CONFIG && window.CONFIG.language) || 'de'; + var entry = window.TRANSLATIONS[key]; + if (!entry) return key; + return entry[lang] || entry.de || key; +}; + +window.t = window.getTranslation; \ No newline at end of file diff --git a/index.html b/index.html index 3f95943..a0ae7c7 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ Vanta Clouds +