Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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.
20 changes: 10 additions & 10 deletions credentialsd-ui/data/resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<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>
Expand All @@ -69,7 +69,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 +110,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,13 +155,13 @@
<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>
Expand All @@ -184,13 +184,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 +201,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 +214,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
218 changes: 218 additions & 0 deletions credentialsd-ui/po/credentialsd-ui.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
msgid ""
msgstr ""
"Project-Id-Version: credentialsd-ui\n"
"Report-Msgid-Bugs-To: \"https://github.com/linux-credentials/credentialsd/"
"issues\"\n"
"POT-Creation-Date: 2025-10-24 08:05+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#. Insert your license of choice here
#. <project_license>LGPL-3.0-only</project_license>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain more about the issue that occurs here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running meson compile credentialsd-ui-pot, the license-field gets automatically filled with MIT, and one has to manually revert that change back to LGPL, before committing.
I have not found a way to tell gettext to use the correct license here when it auto-generates the file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we skip checking in this file? In another project where we use gettext, we only check in the .po files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, yes. But the .po-files have the same problem with the license-string.
And it may be a tiny bit easier to add new languages with the pot-file there (although that may be debatable).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the other project, msgmerge which update the .po file doesn't enforce any license on the .po file. I'll try your branch later today and see if I can tame the tools here as well ;)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I looked closer into this. It is actually not any metadata about the project, it's only some surrounding context to help the translator for the next string to translate, "Credential Manager". It's extracted from data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in so that's where we should change.

I'm not sure if the strings in data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in are translated in the app so maybe easier to just remove that file from credentialsd-ui/po/POTFILES.in

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow. Now that you say it, it's so obvious. 🤦
Thank for digging into that! That file needs to be reworked completely anyways. I'm leaving it in for now.

#: data/xyz.iinuwa.credentialsd.CredentialsUi.desktop.in.in:2
#: data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in:8
#: src/gui/view_model/gtk/mod.rs:372
msgid "Credential Manager"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.desktop.in.in:3
#: data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in:9
msgid "Write a GTK + Rust application"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.desktop.in.in:9
msgid "Gnome;GTK;"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.gschema.xml.in:6
msgid "Window width"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.gschema.xml.in:10
msgid "Window height"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.gschema.xml.in:14
msgid "Window maximized state"
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in:11
msgid ""
"A boilerplate template for GTK + Rust. It uses Meson as a build system and "
"has flatpak support by default."
msgstr ""

#: data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in:16
msgid "Registering a credential"
msgstr ""

#. developer_name tag deprecated with Appstream 1.0
#: data/xyz.iinuwa.credentialsd.CredentialsUi.metainfo.xml.in.in:34
msgid "Isaiah Inuwa"
msgstr ""

#: data/resources/ui/shortcuts.ui:11
msgctxt "shortcut window"
msgid "General"
msgstr ""

#: data/resources/ui/shortcuts.ui:14
msgctxt "shortcut window"
msgid "Show Shortcuts"
msgstr ""

#: data/resources/ui/shortcuts.ui:20
msgctxt "shortcut window"
msgid "Quit"
msgstr ""

#: data/resources/ui/window.ui:6
msgid "_Preferences"
msgstr ""

#: data/resources/ui/window.ui:10
msgid "_Keyboard Shortcuts"
msgstr ""

#: data/resources/ui/window.ui:43
msgid "Choose device"
msgstr ""

#: data/resources/ui/window.ui:49
msgid "Devices"
msgstr ""

#: data/resources/ui/window.ui:72
msgid "Plug in security key"
msgstr ""

#: data/resources/ui/window.ui:113
msgid "Scan the QR code to connect your device"
msgstr ""

#: data/resources/ui/window.ui:158 data/resources/ui/window.ui:164
msgid "Choose credential"
msgstr ""

#: data/resources/ui/window.ui:187
msgid "Complete"
msgstr ""

#: data/resources/ui/window.ui:193
msgid "Done!"
msgstr ""

#: data/resources/ui/window.ui:204
msgid "Something went wrong."
msgstr ""

#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:233
msgid ""
"Something went wrong while retrieving a credential. Please try again later "
"or use a different authenticator."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:139
msgid "Enter your PIN. One attempt remaining."
msgid_plural "Enter your PIN. %d attempts remaining."
msgstr[0] ""
msgstr[1] ""

#: src/gui/view_model/gtk/mod.rs:145
msgid "Enter your PIN."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:154
msgid "Touch your device again. One attempt remaining."
msgid_plural "Touch your device again. %d attempts remaining."
msgstr[0] ""
msgstr[1] ""

#: src/gui/view_model/gtk/mod.rs:160
msgid "Touch your device."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:165
msgid "Touch your device"
msgstr ""

#: src/gui/view_model/gtk/mod.rs:168
msgid "Scan the QR code with your device to begin authentication."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:178
msgid ""
"Connecting to your device. Make sure both devices are near each other and "
"have Bluetooth enabled."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:186
msgid "Device connected. Follow the instructions on your device"
msgstr ""

#: src/gui/view_model/gtk/mod.rs:312
msgid "Insert your security key."
msgstr ""

#: src/gui/view_model/gtk/mod.rs:328
msgid "Multiple devices found. Please select with which to proceed."
msgstr ""

#: src/gui/view_model/gtk/device.rs:57
msgid "A Bluetooth device"
msgstr ""

#: src/gui/view_model/gtk/device.rs:58
msgid "This device"
msgstr ""

#: src/gui/view_model/gtk/device.rs:59
msgid "A mobile device"
msgstr ""

#: src/gui/view_model/gtk/device.rs:60
msgid "Linked Device"
msgstr ""

#: src/gui/view_model/gtk/device.rs:61
msgid "An NFC device"
msgstr ""

#: src/gui/view_model/gtk/device.rs:62
msgid "A security key"
msgstr ""

#: src/gui/view_model/mod.rs:65
msgid "Create new credential"
msgstr ""

#: src/gui/view_model/mod.rs:66
msgid "Use a credential"
msgstr ""

#: src/gui/view_model/mod.rs:173
msgid "Failed to select credential from device."
msgstr ""

#: src/gui/view_model/mod.rs:227
msgid "No matching credentials found on this authenticator."
msgstr ""

#: src/gui/view_model/mod.rs:230
msgid ""
"No more PIN attempts allowed. Try removing your device and plugging it back "
"in."
msgstr ""

#: src/gui/view_model/mod.rs:236
msgid "This credential is already registered on this authenticator."
msgstr ""

#: src/gui/view_model/mod.rs:284
msgid "Something went wrong. Try again later or use a different authenticator."
msgstr ""
Loading