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

Pass the changed language to the Software service and to libzypp #875

Merged
merged 3 commits into from
Nov 16, 2023

Conversation

lslezak
Copy link
Contributor

@lslezak lslezak commented Nov 16, 2023

Problem

When changing the display language in the web frontend the change is not propagated to the Software service. From the y2log:

2023-11-16 09:36:22 <1> localhost.localdomain(1708) [Ruby] agama/ui_locale.rb(change_locale):52 set yast language to es_ES
2023-11-16 09:36:22 <1> localhost.localdomain(1710) [Ruby] agama/ui_locale.rb(change_locale):52 set yast language to es_ES

So the change_locale callback was called only twice. According to the PID numbers only for the Manager and Storage service, not for the Software service.

Solution

Just calling the export function before adding the language change callback in the Software service helped.

But actually I'm not sure whether this is the right fix. The same order is used in the Manager and Storage services where it works fine. Maybe there is some race condition and moving the code earlier/later just accidentally removed that collision and the problem is still there. 🤔

(I updated the order also in the Storage and Manager service so it is consistent.)

With the "fix" the language change callback is correctly called triple times with all services (including the Software service).

2023-11-16 09:46:46 <1> localhost.localdomain(2765) [Ruby] agama/ui_locale.rb(change_locale):52 set yast language to es_ES
2023-11-16 09:46:46 <1> localhost.localdomain(2767) [Ruby] agama/ui_locale.rb(change_locale):52 set yast language to es_ES
...
2023-11-16 09:46:46 <1> localhost.localdomain(2771) [Ruby] agama/ui_locale.rb(change_locale):52 set yast language to es_ES

Additional Fix

In the language change callback I added code which forwards the change also to libzypp. With this fix we can also display localized pattern names and descriptions. See the screenshot below.

But it still needs some improvement, libzypp uses the locale set at the repository refresh time, if the language is changed later then it is not reflected. It only works after manually changing the product to install which reloads the repository again.

But that's a different problem reported in #859. This fix at least proves that we can display also translated patterns, it's rather just a proof of concept.

Testing

  • Tested manually

Screenshots

I tested the pattern selector with the Spanish language.

Note: Some texts are not translated, but that is not Agama fault, the translations come from the package repository.

patterns-spanish

@coveralls
Copy link

coveralls commented Nov 16, 2023

Coverage Status

coverage: 75.538% (-0.04%) from 75.58%
when pulling 48448c8 on sw_service_language
into e6e6e6b on master.

# We need locale for data from users
locale_client = Clients::Locale.new
# TODO: test if we need to pass block with additional actions
@ui_locale = UILocale.new(locale_client)
export
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting that it helps. I actually would expect issues in other way. When you export service and then localize it, so I see small window when you can get unlocalized texts.

service/package/rubygem-agama.changes Outdated Show resolved Hide resolved
Co-authored-by: Imobach González Sosa <igonzalezsosa@suse.com>
@lslezak lslezak merged commit 7785807 into master Nov 16, 2023
3 checks passed
@lslezak lslezak deleted the sw_service_language branch November 16, 2023 16:36
@imobachgs imobachgs mentioned this pull request Dec 2, 2023
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.

4 participants