From a756ee85e6aed505c83c6d5caeab24f759aedad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Thu, 11 Jan 2024 13:05:54 +0100 Subject: [PATCH] Translate pattern descriptions After changing the language refresh the repositories and reload the data to get the pattern descriptions in the new language. The selected packages need to be restored after the reload, the current selection is lost. --- service/lib/agama/dbus/software_service.rb | 44 +++++++++++++++++----- service/package/rubygem-agama.changes | 5 +++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/service/lib/agama/dbus/software_service.rb b/service/lib/agama/dbus/software_service.rb index 245f2f6a97..efcdf52372 100644 --- a/service/lib/agama/dbus/software_service.rb +++ b/service/lib/agama/dbus/software_service.rb @@ -59,15 +59,8 @@ def start # registering the language change callback to work properly export @ui_locale = UILocale.new(Clients::Locale.instance) do |locale| - # set the locale in the Language module, when changing the repository - # (product) it calls Pkg.SetTextLocale(Language.language) internally - Yast::Language.Set(locale) - # set libzypp locale (for communication only, Pkg.SetPackageLocale - # call can be used for installing the language packages) - Yast::Pkg.SetTextLocale(locale) - # TODO: libzypp shows the pattern names and descriptions using the - # locale set at the repository refresh time, here we should refresh - # the repositories with the new locale + # call the language change handler + locale_handler(locale) end end @@ -101,6 +94,39 @@ def dbus_objects Agama::DBus::Software::Proposal.new(logger) ] end + + # Language change callback handler, activate new locale in the libzypp backend + # @param locale [String] the new locale + def locale_handler(locale) + # set the locale in the Language module, when changing the repository + # (product) it calls Pkg.SetTextLocale(Language.language) internally + Yast::Language.Set(locale) + + # set libzypp locale (for communication only, Pkg.SetPackageLocale + # call can be used for *installing* the language packages) + Yast::Pkg.SetTextLocale(locale) + + # refresh all enabled repositories to download the missing translation files + Yast::Pkg.SourceGetCurrent(true).each do |src| + Yast::Pkg.SourceForceRefreshNow(src) + end + + # remember the currently selected packages and patterns by YaST + # (ignore the automatic selections done by the solver) + # + # NOTE: we will need to handle also the tabooed and soft-locked objects + # when we allow to set them via UI or CLI + selected = Y2Packager::Resolvable.find(status: :selected, transact_by: :appl_high) + + # save and reload all repositories to activate the new translations + Yast::Pkg.SourceSaveAll + Yast::Pkg.SourceFinishAll + Yast::Pkg.SourceRestore + Yast::Pkg.SourceLoad + + # restore back the selected objects + selected.each { |s| Yast::Pkg.ResolvableInstall(s.name, s.kind) } + end end end end diff --git a/service/package/rubygem-agama.changes b/service/package/rubygem-agama.changes index 6ff8911f76..4cc4d3d58e 100644 --- a/service/package/rubygem-agama.changes +++ b/service/package/rubygem-agama.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jan 11 12:08:29 UTC 2024 - Ladislav Slezák + +- Translate the pattern descriptions (gh#openSUSE/agama#859) + ------------------------------------------------------------------- Thu Dec 21 14:23:48 UTC 2023 - Imobach Gonzalez Sosa