Skip to content

Commit 235e8db

Browse files
A6GibKmbilelmoussaoui
authored andcommitted
server: Use formatx for translatable strings
See https://www.gnu.org/software/gettext/manual/html_node/Rust.html. This requires xgettext 0.24, otherwise the translatable strings won't be extracted. Can be tested with `meson compile -C $builddir oo7-daemon-pot`.
1 parent 65dba5a commit 235e8db

5 files changed

Lines changed: 23 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ base64 = "0.22"
1515
caps = "0.5"
1616
clap.workspace = true
1717
enumflags2 = "0.7"
18+
formatx = "0.2"
1819
gettext-rs = {version = "0.7", features = ["gettext-system"]}
1920
hkdf = { version = "0.12", optional = true }
2021
libc = "0.2"

server/src/gnome/prompter.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use formatx::formatx;
34
use gettextrs::gettext;
45
use oo7::{Key, ashpd::WindowIdentifierType, dbus::ServiceError};
56
use serde::{Deserialize, Serialize};
@@ -12,7 +13,6 @@ use zbus::zvariant::{
1213
use super::secret_exchange;
1314
use crate::{
1415
error::custom_service_error,
15-
i18n::i18n_f,
1616
prompt::{Prompt, PromptRole},
1717
service::Service,
1818
};
@@ -138,10 +138,13 @@ impl Properties {
138138
Self {
139139
title: Some(gettext("Unlock Keyring")),
140140
message: Some(gettext("Authentication required")),
141-
description: Some(i18n_f(
142-
"An application wants access to the keyring '{}', but it is locked",
143-
&[keyring],
144-
)),
141+
description: Some(
142+
formatx!(
143+
gettext("An application wants access to the keyring '{}', but it is locked",),
144+
keyring,
145+
)
146+
.expect("Wrong format in translatable string"),
147+
),
145148
warning: warning.map(ToOwned::to_owned),
146149
password_new: None,
147150
password_strength: None,
@@ -157,10 +160,13 @@ impl Properties {
157160
Self {
158161
title: Some(gettext("New Keyring Password")),
159162
message: Some(gettext("Choose password for new keyring")),
160-
description: Some(i18n_f(
161-
"An application wants to create a new keyring called '{}'. Choose the password you want to use for it.",
162-
&[label],
163-
)),
163+
description: Some(
164+
formatx!(
165+
gettext("An application wants to create a new keyring called '{}'. Choose the password you want to use for it."),
166+
&label
167+
)
168+
.expect("Wrong format in translatable string")
169+
),
164170
warning: None,
165171
password_new: Some(true),
166172
password_strength: None,

server/src/i18n.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

server/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ mod collection;
33
mod error;
44
#[allow(unused)]
55
mod gnome;
6-
mod i18n;
76
mod item;
87
mod pam_listener;
98
mod prompt;

0 commit comments

Comments
 (0)