Skip to content
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

fix(rust): localize the keymaps descriptions #1643

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions rust/agama-server/src/l10n/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -48,6 +45,18 @@ impl Keymap {
}
}

impl Serialize for Keymap {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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
Expand Down
5 changes: 5 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Sep 27 10:44:22 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Expose keymaps localized descriptions (gh#agama-project/agama#1643).

-------------------------------------------------------------------
Wed Sep 25 14:33:50 UTC 2024 - Clemens Famulla-Conrad <[email protected]>

Expand Down