Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Agama translations #677

Merged
merged 1 commit into from Jul 31, 2023
Merged

Load Agama translations #677

merged 1 commit into from Jul 31, 2023

Conversation

lslezak
Copy link
Member

@lslezak lslezak commented Jul 31, 2023

Problem

  • The Agama translations are not loaded from the server
  • Changing the language has no effect although the translations are present on the server

Solution

  • Load the po.js file with translations

Notes

  • Cockpit handles loading of the right translations on the server side, see the note in the HTML code
  • The HTML comment is currently present also in the built production code, later I'll reconfigure webpack to also minify HTML files
  • The defer attribute is needed because the JS modules (index.js) are deferred by default. We need to defer also loading the localization code otherwise calling cockpit.locale() inside po.js would fail because it would not be defined yet. The cockpit.js file is bundled in the index.js file so that file needs to be loaded before the translations.

Testing

  • Tested manually
  • For switching the language use the original Cockpit language selector
    • Change the URL to point to the /cockpit/@localhost/shell/index.html path
    • This displays the full Cockpit web UI
    • Use the Session menu in the top right corner, select the Display language option
    • In the popup list select čeština (Czech)
    • Then go back to Agama (either revert the URL path to simple / or click the Agama label in the left side bar
  • To display a Czech translation use the option menu (the hamburger icon in the top right corner) and select Diagnostic tools -> Show Log. So far there are just few translations to test, see the web/po/cs.po file.
  • The displayed popup with YaST logs contains Zavřít translation for the Close button

Screenshots

The "Close" button with the Czech translation activated

agama_cz

@coveralls
Copy link

Coverage Status

coverage: 72.051%. remained the same when pulling a89b700 on load_translations into 93aaa88 on master.

@lslezak lslezak merged commit 4921861 into master Jul 31, 2023
14 checks passed
@lslezak lslezak deleted the load_translations branch July 31, 2023 08:47
<!--
The Cockpit server returns "po.<LANG>.js" content for the "po.js" request,
the requested language is obtained from the "CockpitLang" cookie sent in
the HTTP header. For missing translations it returns an empty string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For missing translations it returns an empty string.

Does this mean that if I miss to translate some strings, there will be empty texts?

Suggested change
the HTTP header. For missing translations it returns an empty string.
the HTTP header. For missing translations it returns an empty script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants