-
Notifications
You must be signed in to change notification settings - Fork 43
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
UI locale dbus #725
Merged
Merged
UI locale dbus #725
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
eb38c9c
add dbus method for ui locales
jreidinger dde3bb7
add code for ruby services to respect ui locale
jreidinger 117f1ab
add calls to respect ui locale and drop no longer used language service
jreidinger b8da347
Merge remote-tracking branch 'origin/master' into ui_locale_dbus
jreidinger ce6b4e5
Merge remote-tracking branch 'origin/master' into ui_locale_dbus
jreidinger 161ffac
use dbus names as ruby friendly names does not work
jreidinger 1db2adf
try another way to access properties
jreidinger bc444da
fix calling ui locale chagne
jreidinger 5c9b407
add some logging to debug language switching
jreidinger ee23100
log also gettext locale
jreidinger fdb4f5d
add value with testing localized string
jreidinger 5d388b6
try to set lang to get localized string from libstorage
jreidinger 9dd368a
remove unnecessary logging
jreidinger 7b53b13
Update service/lib/agama/ui_locale.rb
jreidinger 12d3d46
Update rust/agama-dbus-server/src/locale.rs
jreidinger fde8366
apply rust fmt
jreidinger d365fa5
apply clippy suggestions
jreidinger cc7cfc5
adapt manager test
jreidinger ba9dc9b
fix typo
jreidinger 51ca721
improve mocking
jreidinger ffb9dfc
changes
jreidinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2022] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "yast" | ||
|
||
Yast.import "WFM" | ||
|
||
module Agama | ||
# Object responsible for managing changes of localization produced by dbus backend. | ||
jreidinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class UILocale | ||
include Yast::I18n | ||
include Yast::Logger | ||
# creates new UILocale object that will handle change of UI locale. | ||
# | ||
# @param [Agama::DBus::Clients::Locale] locale_client to communicate with dbus service | ||
# @yield block is callback that is called when ui locale is changed | ||
# to allow user to call methods that needs retranslation | ||
def initialize(locale_client, &block) | ||
@client = locale_client | ||
change_locale(@client.ui_locale) | ||
@client.on_ui_locale_change do |locale| | ||
change_locale(locale) | ||
block.call(locale) if block_given? | ||
end | ||
end | ||
|
||
private | ||
|
||
def change_locale(locale) | ||
# TODO: check if we can use UTF-8 everywhere including strange arch consoles | ||
Yast::WFM.SetLanguage(locale, "UTF-8") | ||
# explicitelly set ENV to get localization also from libraries like libstorage | ||
ENV["LANG"] = locale + ".UTF-8" | ||
log.info "set yast language to #{locale}" | ||
# explicit call to textdomain to force fast gettext change of language ASAP | ||
textdomain "installation" | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are returning an error if we cannot read any of the dirs, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, any read failure result in error. I would not expect it unless there is some issue with fs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
/usr/share/YaST2/locale/
directory is owned by the baseyast2
package so the error should not happen normally.