Create custom Translation component for better i18n handling (#4431)

* Initial plan

* Implement Translation component with Storybook stories

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Add Jest test for Translation component and demonstrate ?lang=de functionality

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Javascript formatting autofixes

* Create centralized type-safe localization system

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Add @testing-library/react to Translation component tests

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Fix code formatting errors with prettier and eslint

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Revert "Fix code formatting errors with prettier and eslint"

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* fix(js): eslinter errors

* fix(js): unused code warnings

* fix(js): fix additional warnings

* Update Emoji admin page to use new Translation component

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Organize localization keys by logical sections (Frontend, Admin, Common, Testing)

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Organize localization keys by TypeScript namespaces

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* Javascript formatting autofixes

* feat(js): add support for default translated text

* chore: add default lang translations on commit

* fix(js): unused code warnings

* Update OfflineBanner component to use new Translation component

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* fix(js): fix localization extraction job

* chore(js): remove ts-node cli

* fix(css): fix css warning

* feat(js): add some additional translation strings via component

* chore: update extracted translations

* test: add tests for Translation component defaultText and fallback behavior

Co-authored-by: gabek <414923+gabek@users.noreply.github.com>

* chore: update extracted translations

* Javascript formatting autofixes

* chore: call out new Translation component

* fix: linter warning

* chore: updated instructions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gabek <414923+gabek@users.noreply.github.com>
Co-authored-by: Owncast <owncast@owncast.online>
Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Copilot
2025-07-13 02:21:46 -07:00
committed by GitHub
co-authored by gabek copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Owncast Gabe Kangas
parent 7b181aa0a6
commit 29b5100114
23 changed files with 2287 additions and 325 deletions
+11 -3
View File
@@ -16,10 +16,13 @@
"build-styles": "cd ./style-definitions && style-dictionary build && ./build.sh && cd -",
"test": "jest",
"format": "prettier --write **/*.{js,ts,jsx,tsx,css,md,scss}",
"translate": "i18next -c i18next-parser.config.mjs"
"translate": "i18next -c i18next-parser.config.mjs",
"i18n:extract": "node scripts/i18n-extract.js"
},
"dependencies": {
"@ant-design/icons": "4.8.3",
"@babel/parser": "^7.28.0",
"@babel/traverse": "^7.28.0",
"@codemirror/lang-css": "6.3.1",
"@codemirror/lang-html": "^6.4.2",
"@codemirror/lang-javascript": "^6.1.2",
@@ -30,6 +33,8 @@
"@fontsource/inter": "^5.0.0",
"@fontsource/poppins": "5.2.5",
"@next/bundle-analyzer": "^14.0.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@uiw/codemirror-theme-bbedit": "4.23.7",
"@uiw/react-codemirror": "4.23.7",
"@xstate/react": "3.2.2",
@@ -39,6 +44,7 @@
"chart.js": "^4.2.0",
"classnames": "2.5.1",
"date-fns": "^4.0.0",
"glob": "^11.0.3",
"graphemer": "^1.4.0",
"i18next-parser": "^9.1.0",
"i18next-scanner": "^4.6.0",
@@ -92,6 +98,7 @@
"@storybook/react": "^8.3.6",
"@storybook/theming": "^8.3.6",
"@svgr/webpack": "8.1.0",
"@testing-library/react": "^16.3.0",
"@types/chart.js": "2.9.41",
"@types/classnames": "2.3.4",
"@types/jest": "^29.5.0",
@@ -122,6 +129,7 @@
"handlebars": "^4.7.7",
"html-webpack-plugin": "5.6.3",
"install": "^0.13.0",
"jest-environment-jsdom": "^30.0.4",
"knip": "^5.0.0",
"less": "4.2.1",
"less-loader": "12.2.0",
@@ -142,11 +150,11 @@
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^14.0.0",
"ts-jest": "^29.1.0",
"typescript": "5.7.3"
"typescript": "^5.7.3"
},
"overrides": {
"@emoji-mart/react": {
"emoji-mart": "5.2.2"
}
}
}
}