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

Fix unstranlated strings #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

lcaparroz
Copy link
Collaborator

@lcaparroz lcaparroz commented Mar 5, 2025

Problem

Some strings in the UI dialogs are not translated, resulting in text being shown partially in the configured locale language, partially in English.

The issue was originally reported for the Simplified Chinese language, but it can also be replicated for Brazilian Portuguese, leading to infer that probably all translations are affected by the same issue.

Cause

The strings not being translated are marked with the function N_(...), assigned to instance variables that would later be localized with the function _(...), which is quite common when using the gettext Ruby gem.

However, the cause is that the y2tools y2makepot command, used to identify localized strings, doesn't consider the function N_(...) when scanning the files (source code).

Solution

We changed the code to no longer use the function N_(...), only _(...), and adapted the classes that relied on receiving strings with N_(...) through instance variables.

Testing

  • No new unit tests were added: it's only a change to how string localization is handled.
  • It will only be possible to test the effects of this change after a new translation round:
    • Submitting new strings for translation (i18n).
    • Asking for the translation of those strings.
    • Bundling the new translations in the yast2-rmt package.

Meanwhile, you can verify that files previously not considered for translation are caught by the command rake check:pot:

  • src/lib/rmt/maria_db/current_root_password_dialog.rb
  • src/lib/rmt/maria_db/new_root_password_dialog.rb
  • src/lib/rmt/ssl/current_ca_password_dialog.rb
  • src/lib/rmt/ssl/new_ca_password_dialog.rb

Output example from running rake check:pot:

$ rake check:pot
/usr/bin/y2tool y2makepot
Creating ./rmt.pot from  ./src/lib/rmt/execute.rb ./src/lib/rmt/maria_db/current_root_password_dialog.rb ./src/lib/rmt/maria_db/new_root_password_dialog.rb ./src/lib/rmt/shared/input_password_dialog.rb ./src/lib/rmt/shared/set_password_dialog.rb ./src/lib/rmt/ssl/alternative_common_name_dialog.rb ./src/lib/rmt/ssl/certificate_generator.rb ./src/lib/rmt/ssl/current_ca_password_dialog.rb ./src/lib/rmt/ssl/new_ca_password_dialog.rb ./src/lib/rmt/utils.rb ./src/lib/rmt/wizard_final_page.rb ./src/lib/rmt/wizard_firewall_page.rb ./src/lib/rmt/wizard_maria_db_page.rb ./src/lib/rmt/wizard_rmt_service_page.rb ./src/lib/rmt/wizard_scc_page.rb ./src/lib/rmt/wizard_ssl_page.rb ...
rmt.pot: 3 format flags added
Verifying rmt.pot validity...
rmt.pot:8: warning: header field 'Project-Id-Version' still has the initial default value
rmt.pot:8: warning: header field 'Last-Translator' still has the initial default value
rmt.pot:8: warning: header field 'Language-Team' still has the initial default value
rmt.pot:8: warning: header field 'Language' still has the initial default value
...OK
Checking rmt.pot...

You can also read the generated rmt.pot file and verify that the strings previously marked with N_(...) (see the "Files changed" tab) are present there, e.g.:

#: src/lib/rmt/maria_db/current_root_password_dialog.rb:31
msgid "Database root password is required"
msgstr ""

#: src/lib/rmt/maria_db/current_root_password_dialog.rb:32
msgid ""
"In order to setup RMT, database access is required. Please provide the current"
" database root password."
msgstr ""

#: src/lib/rmt/maria_db/current_root_password_dialog.rb:33
msgid "MariaDB root &password"
msgstr ""

Screenshots

N/A.

Mark strings that previously were not marked for translation, making the
UI show text partially in English and partially on another language on
some dialogs.

Changed shared dialog classes to assume instance variables holds already
localized strings, no need to further call gettext functions on them.
This means classes that inherit these shared ones should no longer use
'N_(...)', but instead '_(...)'.

Refs: bsc#1127676
Add a step on the GitHub Actions job "Rubocop" to install the package
'ruby-devel', which provide Ruby's headers, required by the 'racc'
(installed with 'bundle install').
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13679662955

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 98.56%

Totals Coverage Status
Change from base Build 10734341110: 0.004%
Covered Lines: 1643
Relevant Lines: 1667

💛 - Coveralls

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.

2 participants