Skip to content

Commit

Permalink
fix: properly handle installer language changes (#1746)
Browse files Browse the repository at this point in the history
## Problem

Problems:

- [x] It is not possible to change the language. See
[bsc#1233160](https://bugzilla.suse.com/show_bug.cgi?id=1233160).
- [x] Changing to Portuguese does not work (it might be related to the
code, `pt-BR`).
- [x] The message while reloading the software translations is in the
old language.
- [x] #1724
- [x] #860

## Solution

Fix the D-Bus path of the LocaleProxy to the Manager's
`org.opensuse.Agama1.Locale` interface.

## Testing

- Tested manually
  • Loading branch information
imobachgs authored Nov 14, 2024
2 parents 9dc7bef + e4631f9 commit 198576f
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 215 deletions.
1 change: 1 addition & 0 deletions rust/agama-lib/src/localization/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use zbus::proxy;
#[proxy(
default_service = "org.opensuse.Agama1",
default_path = "/org/opensuse/Agama1/Locale",
interface = "org.opensuse.Agama1.Locale",
assume_defaults = true
)]
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/src/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ mod issues;
pub use issues::IssuesProxy;

mod locale;
pub use locale::LocaleProxy;
pub use locale::LocaleMixinProxy;

pub mod jobs;
9 changes: 5 additions & 4 deletions rust/agama-lib/src/proxies/locale.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # D-Bus interface proxy for: `org.opensuse.Agama1.Locale`
//! # D-Bus interface proxy for: `org.opensuse.Agama1.LocaleMixin`
//!
//! This code was generated by `zbus-xmlgen` `5.0.0` from D-Bus introspection data.
//! Source: `org.opensuse.Agama1.Manager.bus.xml`.
Expand All @@ -20,11 +20,12 @@
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
use zbus::proxy;
#[proxy(
default_service = "org.opensuse.Agama1",
interface = "org.opensuse.Agama1.Locale",
default_service = "org.opensuse.Agama.Manager1",
default_path = "/org/opensuse/Agama/Manager1",
interface = "org.opensuse.Agama1.LocaleMixin",
assume_defaults = true
)]
pub trait Locale {
pub trait LocaleMixin {
/// SetLocale method
fn set_locale(&self, locale: &str) -> zbus::Result<()>;
}
2 changes: 1 addition & 1 deletion rust/agama-server/src/l10n/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
};
use agama_lib::{
error::ServiceError, localization::model::LocaleConfig, localization::LocaleProxy,
proxies::LocaleProxy as ManagerLocaleProxy,
proxies::LocaleMixinProxy as ManagerLocaleProxy,
};
use agama_locale_data::LocaleId;
use axum::{
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 13 12:03:02 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Properly update the localization settings of the D-Bus services
(bsc#1233159, bsc#1233160).

-------------------------------------------------------------------
Mon Nov 11 09:52:59 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/dbus/interfaces/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Locale
include Yast::I18n
include Yast::Logger

LOCALE_INTERFACE = "org.opensuse.Agama1.Locale"
LOCALE_INTERFACE = "org.opensuse.Agama1.LocaleMixin"

def self.included(base)
base.class_eval do
Expand Down
1 change: 1 addition & 0 deletions service/lib/agama/storage/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def system_issues
# @return [Array<Issue>]
def probing_issues
y2storage_issues = Y2Storage::StorageManager.instance.raw_probed.probing_issues
return [] if y2storage_issues.nil?

y2storage_issues.map do |y2storage_issue|
Issue.new(y2storage_issue.message,
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 13 12:14:06 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Do not crash when trying to change the language of the storage
service before the "config" phase (gh#agama-project/agama#1746).

-------------------------------------------------------------------
Tue Nov 5 16:11:35 UTC 2024 - Martin Vidner <[email protected]>

Expand Down
11 changes: 11 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Nov 13 12:06:41 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Several translation fixes (gh#agama-project/agama#1746):
- Use the correct capitalization for RFC 5646 language tags
(e.g., "pt-BR" instead of "pt-BR" instead of "pt-br") (bsc#1233160).
- Translate the products descriptions when the user changes
the language (gh#agama-project/agama#1724).
- Fallback to a similar language if the given one is not supported
(e.g., "es" for "es-AR") (gh#agama-project/agama#860).

-------------------------------------------------------------------
Wed Nov 6 06:06:51 UTC 2024 - Michal Filka <[email protected]>

Expand Down
126 changes: 63 additions & 63 deletions web/share/locales.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
{
"af": "za",
"am": "et",
"ar": "eg",
"ast": "es",
"be": "by",
"bg": "bg",
"bn": "in",
"bs": "ba",
"ca": "es",
"cs": "cz",
"cy": "gb",
"da": "dk",
"de": "de",
"en": "us",
"el": "gr",
"es": "es",
"et": "ee",
"eu": "es",
"fa": "ir",
"fi": "fi",
"fr": "fr",
"gl": "es",
"gu": "in",
"he": "il",
"hi": "in",
"hr": "hr",
"hu": "hu",
"id": "id",
"it": "it",
"ja": "jp",
"ka": "kz",
"km": "kh",
"kn": "in",
"ko": "kr",
"lt": "lt",
"lv": "lv",
"mk": "mk",
"mr": "in",
"ms": "my",
"my": "mm",
"nb": "no",
"nds": "de",
"ne": "np",
"nl": "nl",
"nn": "no",
"pa": "in",
"pl": "pl",
"pt": "pt",
"ro": "ro",
"ru": "ru",
"si": "lk",
"sk": "sk",
"sl": "si",
"sq": "al",
"sr": "rs",
"sv": "se",
"ta": "in",
"tg": "tj",
"th": "th",
"tr": "tr",
"uk": "ua",
"vi": "vn",
"zu": "za"
"af": "ZA",
"am": "ET",
"ar": "EG",
"ast": "ES",
"be": "BY",
"bg": "BG",
"bn": "IN",
"bs": "BA",
"ca": "ES",
"cs": "CZ",
"cy": "GB",
"da": "DK",
"de": "DE",
"en": "US",
"el": "GR",
"es": "ES",
"et": "EE",
"eu": "ES",
"fa": "IR",
"fi": "FI",
"fr": "FR",
"gl": "ES",
"gu": "IN",
"he": "IL",
"hi": "IN",
"hr": "HR",
"hu": "HU",
"id": "ID",
"it": "IT",
"ja": "JP",
"ka": "KZ",
"km": "KH",
"kn": "IN",
"ko": "KR",
"lt": "LT",
"lv": "LV",
"mk": "MK",
"mr": "IN",
"ms": "MY",
"my": "MM",
"nb": "NO",
"nds": "DE",
"ne": "NP",
"nl": "NL",
"nn": "NO",
"pa": "IN",
"pl": "PL",
"pt": "PT",
"ro": "RO",
"ru": "RU",
"si": "LK",
"sk": "SK",
"sl": "SI",
"sq": "AL",
"sr": "RS",
"sv": "SE",
"ta": "IN",
"tg": "TJ",
"th": "TH",
"tr": "TR",
"uk": "UA",
"vi": "VN",
"zu": "ZA"
}
13 changes: 7 additions & 6 deletions web/share/update-languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#

from argparse import ArgumentParser
from typing import Optional
from langtable import language_name
from pathlib import Path
import json
Expand All @@ -32,9 +33,9 @@

class Locale:
language: str
territory: str
territory: Optional[str]

def __init__(self, language: str, territory: str = None):
def __init__(self, language: str, territory: Optional[str] = None):
self.language = language
self.territory = territory

Expand All @@ -44,13 +45,13 @@ def code(self):
def name(self, include_territory: bool = False):
if include_territory:
return language_name(languageId=self.language,
territoryId=self.territory.upper())
territoryId=self.territory)
else:
return language_name(languageId=self.language)


class PoFile:
path: str
path: Path
locale: Locale

def __init__(self, path: Path):
Expand Down Expand Up @@ -85,7 +86,7 @@ class Languages:
def __init__(self):
self.content = dict()

def update(self, po_files, lang2territory: str, threshold: int):
def update(self, po_files, lang2territory, threshold: int):
"""
Generate the list of supported locales
Expand All @@ -97,7 +98,7 @@ def update(self, po_files, lang2territory: str, threshold: int):
:param threshold Percentage of the strings that must be covered to
include the locale in the manifest
"""
supported = [Locale("en", "us")]
supported = [Locale("en", "US")]

for path in po_files:
po_file = PoFile(path)
Expand Down
4 changes: 2 additions & 2 deletions web/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jest.mock("~/api/l10n", () => ({
...jest.requireActual("~/api/l10n"),
fetchConfig: jest.fn().mockResolvedValue({
uiKeymap: "en",
uiLocale: "en_us",
uiLocale: "en_US",
}),
updateConfig: jest.fn(),
}));
Expand Down Expand Up @@ -98,7 +98,7 @@ jest.mock("~/components/product/ProductSelectionProgress", () => () => <div>Prod
describe("App", () => {
beforeEach(() => {
// setting the language through a cookie
document.cookie = "agamaLang=en-us; path=/;";
document.cookie = "agamaLang=en-US; path=/;";
(createClient as jest.Mock).mockImplementation(() => {
return {};
});
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/core/InstallerOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function InstallerOptions({ isOpen = false, onClose }: InstallerO
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setInProgress(true);
changeKeymap(keymap);
await changeKeymap(keymap);
changeLanguage(language)
.then(close)
.catch(() => setInProgress(false));
Expand Down
Loading

0 comments on commit 198576f

Please sign in to comment.