-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring the web translations (#1777)
## Problem - The web translations still use the original Cockpit mechanism for creating and loading the translations - That uses a server based logic which has quite some drawbacks - We have to reimplement the very same logic in a Webpack plugin to make it work also in the local development server (`npm run server`). And unfortunately we cannot share the code because it is Rust vs. Javascript... - This will not work in the Agama online demo site with completely static files (without any server side logic, everything needs to be on the client side). - For me the original logic was quite strange, why the server should decide which translations should the client use? It should be completely handled on the client side, there is no reason for the special server logic. The server should just report the available translations and let the client to pick and use the right one. - The old implementation has also some ugly parts like requiring a global Javascript variable... ## Solution - Move the translation logic from the server to the client (browser) - Use dynamic imports instead of HTTP redirection ## Implementation details - Removed the `po.js` handler from the Agama HTTP server - Removed the `po.js` handler from the Webpack development server - Removed the original Gettext PO files from Git, replaced by already converted JS files - Removed the Cockpit Webpack plugin for converting PO files to JS, replaced by a simple script with similar functionality. (As a bonus the code was fixed to avoid adding unnecessary `null` values into the output.) - Added dynamic import for downloading the requested translations - Some code cleanup (removing the global JS object) - Moved the `jed` and `gettext-parser` NPM dependencies to the PO->JS converter, that means those NPM packages are installed only when converting the PO files to JS (basically only in the GitHub action which merges them), they are not installed when building the Agama web frontend ## Testing - Tested manually, loading the translations works fine - I manually triggered the GitHub Action which merges the translations from Weblate. It works fine, the test run opened this [pull request](#1780) with updated translations (there are more changes as it was executed in the same branch as this pull request).
- Loading branch information
Showing
50 changed files
with
21,001 additions
and
57,754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
------------------------------------------------------------------- | ||
Thu Nov 28 15:58:59 UTC 2024 - Ladislav Slezák <[email protected]> | ||
|
||
- Drop the handler for the "po.js" path in the HTTP server, | ||
the web frontend now uses dynamic imports for loading the | ||
translation files (gh#agama-project/agama#1777) | ||
|
||
------------------------------------------------------------------- | ||
Thu Nov 28 11:07:58 UTC 2024 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ coverage/ | |
dist/ | ||
/*.spec | ||
/.vagrant | ||
package-lock.json | ||
Test*FAIL* | ||
/bots | ||
test/common/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.