Skip to content

Commit

Permalink
Merge pull request #36 from MTRNord/patch-1
Browse files Browse the repository at this point in the history
Add explanation for how to do translations and use correct paths in the po/POTFILES.in file.
  • Loading branch information
AaronErhardt authored Nov 10, 2024
2 parents ba0957e + 794d495 commit 074632a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ Once the project is build, run the command below. Replace Replace `<application_
flatpak-builder --run flatpak_app build-aux/<application_id>.Devel.json <project_name>
```

## Translations with Gettext

The template uses `gettext` as a framework for translations using [`gettext-rs`](https://github.com/gettext-rs/gettext-rs). The basic files for this can be found in the `po` folder.
While meson will take care of building the translations the extraction and translation itself has to be done manually.

### Extracting translatable strings

First of all you have to have `gettext` installed on your system. With that you then are able to use `xgettext` as following to extract the translatable strings:

```shell
xgettext --package-name=<project_name> --package-version=main --msgid-bugs-address=https://github.com/<project_name>/<project_name>/issues --files-from=po/POTFILES.in --output=po/<project_name>.pot
```

Note that you might need to update the `po/POTFILES.in` file to reflect the files of your process. This describes where `xgettext` is going to search for strings to translate.

### Translating the translatable strings

To translate the strings you need to use po files. Tools like Poedit allow you to generate these from the `po/<project_name>.pot` file.
It also allows you to sync the `po/<project_name>.pot` when you rerun `xgettext`.

When adding a po file also make sure to add the language code to `po/LINGUAS`.

## Community

Join the GNOME and gtk-rs community!
Expand Down
4 changes: 2 additions & 2 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ data/com.belmoussaoui.GtkRustTemplate.desktop.in.in
data/com.belmoussaoui.GtkRustTemplate.gschema.xml.in
data/com.belmoussaoui.GtkRustTemplate.metainfo.xml.in.in
data/resources/ui/shortcuts.ui
data/resources/ui/window.ui
src/application.rs
src/app.rs
src/main.rs

0 comments on commit 074632a

Please sign in to comment.