Skip to content
Open
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
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,25 @@ formatting and linting tools [mentioned above](#code-formatting-and-linting).
You should also follow the install instructions in [`BUILDING.md`](/BUILDING.md)
and execute authentication flows in a browser to ensure that everything
still works as it should.

# Translations

credentialsd-ui is using [gettext-rs](https://github.com/gettext-rs/gettext-rs) to translate user-facing strings.

Please wrap all user-facing messages in `gettext("my string")`-calls and add the files you add them to, to `credentialsd-ui/po/POTFILES`.

If you introduce a new language, also add them to `credentialsd-ui/po/LINGUAS`.

Then `cd` into your build-directory (e.g. `build/`) and run

```
# To update the POT template file, in case new strings have been added in the sources
meson compile credentialsd-ui-pot
# and to update the individual language files
meson compile credentialsd-ui-update-po
```
to update the template, so it contains all messages to be translated.

Meson should take care of building the translations.

When using the development-profile to build, meson will use the locally built translations.
17 changes: 15 additions & 2 deletions credentialsd-common/src/model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Display;
use std::{fmt::Display, path::PathBuf};

use serde::{Deserialize, Serialize};
use zvariant::{SerializeDict, Type};
Expand Down Expand Up @@ -170,9 +170,22 @@ impl Transport {
}
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, Type)]
pub struct RequestingApplication {
pub name: String,
pub path: PathBuf,
pub pid: u32,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, Type)]
pub struct RequestingParty {
pub rp_id: String,
pub origin: String,
}

#[derive(Serialize, Deserialize)]
pub enum ViewUpdate {
SetTitle(String),
SetTitle((String, String)),
SetDevices(Vec<Device>),
SetCredentials(Vec<Credential>),

Expand Down
4 changes: 3 additions & 1 deletion credentialsd-common/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use zvariant::{
Signature, Structure, StructureBuilder, Type, Value, signature::Fields,
};

use crate::model::{BackgroundEvent, Operation};
use crate::model::{BackgroundEvent, Operation, RequestingApplication};

const TAG_VALUE_SIGNATURE: &Signature = &Signature::Structure(Fields::Static {
fields: &[&Signature::U8, &Signature::Variant],
Expand Down Expand Up @@ -484,6 +484,8 @@ where
pub struct ViewRequest {
pub operation: Operation,
pub id: RequestId,
pub rp_id: String,
pub requesting_app: RequestingApplication,
}

fn value_to_owned(value: &Value<'_>) -> OwnedValue {
Expand Down
2 changes: 1 addition & 1 deletion credentialsd-ui/data/resources/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.title-header{
font-size: 36px;
font-size: 24px;
font-weight: bold;
}
51 changes: 39 additions & 12 deletions credentialsd-ui/data/resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<binding name="label">
Expand All @@ -34,24 +35,49 @@
</style>
</object>
</child>
<child>
<object class="GtkSeparator"></object>
</child>
<child>
<object class="GtkLabel">
<property name="wrap">true</property>
<property name="use-markup">true</property>
<binding name="label">
<lookup name="subtitle">
<lookup name="view-model">
CredentialsUiWindow
</lookup>
</lookup>
</binding>
<style>
<class name="subtitle-header"/>
</style>
</object>
</child>

<child>
<object class="GtkSeparator"></object>
</child>

<child>
<object class="GtkStack" id="stack">

<child>
<object class="GtkStackPage">
<property name="name">choose_device</property>
<property name="title">Choose device</property>
<property name="title" translatable="yes">Choose device</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="label">Devices</property>
<property name="label" translatable="yes">Devices</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="min-content-height">256</property>
<property name="vexpand">true</property>
<property name="max-content-height">256</property>
<binding name="child">
<lookup name="devices">
<lookup name="view-model">
Expand All @@ -69,7 +95,7 @@
<child>
<object class="GtkStackPage">
<property name="name">usb</property>
<property name="title">Plug in security key</property>
<property name="title" translatable="yes">Plug in security key</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
Expand Down Expand Up @@ -110,7 +136,7 @@
<child>
<object class="GtkStackPage">
<property name="name">hybrid_qr</property>
<property name="title">Scan the QR code to connect your device</property>
<property name="title" translatable="yes">Scan the QR code to connect your device</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
Expand Down Expand Up @@ -155,18 +181,19 @@
<child>
<object class="GtkStackPage">
<property name="name">choose_credential</property>
<property name="title">Choose credential</property>
<property name="title" translatable="yes">Choose credential</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="label">Choose credential</property>
<property name="label" translatable="yes">Choose credential</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="min-content-height">256</property>
<property name="vexpand">true</property>
<property name="max-content-height">256</property>
<binding name="child">
<lookup name="credentials">
<lookup name="view-model">
Expand All @@ -184,13 +211,13 @@
<child>
<object class="GtkStackPage">
<property name="name">completed</property>
<property name="title">Complete</property>
<property name="title" translatable="yes">Complete</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="label">Done!</property>
<property name="label" translatable="yes">Done!</property>
</object>
</child>
</object>
Expand All @@ -201,7 +228,7 @@
<child>
<object class="GtkStackPage">
<property name="name">failed</property>
<property name="title">Something went wrong.</property>
<property name="title" translatable="yes">Something went wrong.</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
Expand All @@ -214,7 +241,7 @@
</lookup>
</lookup>
</binding>
<property name="label">Something went wrong while retrieving a credential. Please try again later or use a different authenticator.</property>
<property name="label" translatable="yes">Something went wrong while retrieving a credential. Please try again later or use a different authenticator.</property>
</object>
</child>
</object>
Expand Down
8 changes: 5 additions & 3 deletions credentialsd-ui/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ localedir = prefix / get_option('localedir')
datadir = prefix / get_option('datadir')
pkgdatadir = datadir / gui_executable_name
iconsdir = datadir / 'icons'
podir = meson.project_source_root() / meson.current_source_dir() / 'po'
gettext_package = gui_executable_name

if get_option('profile') == 'development'
profile = 'Devel'
Expand Down Expand Up @@ -71,6 +69,10 @@ if get_option('cargo_offline') == true
cargo_options += ['--offline']
endif

# Localization setup
podir = meson.project_source_root() / meson.current_source_dir() / 'po'
gettext_package = gui_executable_name

subdir('data')
subdir('po')
subdir('src')
Expand All @@ -79,4 +81,4 @@ gnome.post_install(
gtk_update_icon_cache: true,
glib_compile_schemas: true,
update_desktop_database: true,
)
)
2 changes: 2 additions & 0 deletions credentialsd-ui/po/LINGUAS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en_US
de_DE
10 changes: 6 additions & 4 deletions credentialsd-ui/po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
data/xyz.iinuwa.CredentialManager.desktop.in.in
data/xyz.iinuwa.CredentialManager.gschema.xml.in
data/xyz.iinuwa.CredentialManager.metainfo.xml.in.in
data/xyz.iinuwa.credentialsd.CredentialsUi.desktop.in.in
data/xyz.iinuwa.credentialsd.CredentialsUi.gschema.xml.in
data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in
data/resources/ui/shortcuts.ui
data/resources/ui/window.ui
src/application.rs
src/gui/view_model/gtk/mod.rs
src/gui/view_model/gtk/device.rs
src/gui/view_model/mod.rs
Loading