Skip to content

Commit

Permalink
Translate pattern descriptions (#991)
Browse files Browse the repository at this point in the history
## Problem

- After changing the language the pattern descriptions are not
translated (actually they keep the previous locale setting)
- #859 

## Solution

- 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.

## Notes

The pattern groups (e.g. "Graphical Environments", "Base Technologies")
are not translated but they come from libzypp as well. But as they are
not translated also in YaST I guess there is some serious problem, maybe
there is missing translation support for that... I'll check the details
later.

## Testing

- Tested manually

## Screenshots

Switching from English to Spanish, the previously selected patterns are
kept.

The Gnome pattern description is not translated, probably missing
translation or they updated the original text and was not re-translated.
But at least the name is translated.


[patterns.webm](https://github.com/openSUSE/agama/assets/907998/e02569df-4280-40a0-bd73-f9dc2273d201)
  • Loading branch information
lslezak authored Jan 11, 2024
2 parents a805fc2 + a756ee8 commit 8ca724d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
44 changes: 35 additions & 9 deletions service/lib/agama/dbus/software_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions service/package/rubygem-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Jan 11 12:08:29 UTC 2024 - Ladislav Slezák <[email protected]>

- Translate the pattern descriptions (gh#openSUSE/agama#859)

-------------------------------------------------------------------
Thu Dec 21 14:23:48 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

Expand Down

0 comments on commit 8ca724d

Please sign in to comment.