From 8ace87173befa67dcce7ea509c6146c1b2150ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 27 Sep 2024 11:40:02 +0100 Subject: [PATCH 1/2] fix: use keymap localized description when serializing --- rust/agama-server/src/l10n/keyboard.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rust/agama-server/src/l10n/keyboard.rs b/rust/agama-server/src/l10n/keyboard.rs index a10c202ffc..775ea052a3 100644 --- a/rust/agama-server/src/l10n/keyboard.rs +++ b/rust/agama-server/src/l10n/keyboard.rs @@ -20,16 +20,13 @@ use agama_locale_data::{get_localectl_keymaps, keyboard::XkbConfigRegistry, KeymapId}; use gettextrs::*; -use serde::Serialize; -use serde_with::{serde_as, DisplayFromStr}; +use serde::ser::{Serialize, SerializeStruct}; use std::collections::HashMap; -#[serde_as] // Minimal representation of a keymap -#[derive(Clone, Debug, Serialize, utoipa::ToSchema)] +#[derive(Clone, Debug, utoipa::ToSchema)] pub struct Keymap { /// Keymap identifier (e.g., "us") - #[serde_as(as = "DisplayFromStr")] pub id: KeymapId, /// Keymap description description: String, @@ -48,6 +45,18 @@ impl Keymap { } } +impl Serialize for Keymap { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut state = serializer.serialize_struct("Keymap", 2)?; + state.serialize_field("id", &self.id.to_string())?; + state.serialize_field("description", &self.localized_description())?; + state.end() + } +} + /// Represents the keymaps database. /// /// The list of supported keymaps is read from `systemd-localed` and the From 22d4db7258880f995de9b5a5f6a671ed77bf17be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 27 Sep 2024 12:02:03 +0100 Subject: [PATCH 2/2] doc(rust): update changes file --- rust/package/agama.changes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 4541f3dcde..b7951148cd 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Sep 27 10:44:22 UTC 2024 - Imobach Gonzalez Sosa + +- Expose keymaps localized descriptions (gh#agama-project/agama#1643). + ------------------------------------------------------------------- Wed Sep 25 14:33:50 UTC 2024 - Clemens Famulla-Conrad