A comprehensive guide for starting projects with GTK, Rust, Meson, and Flatpak in the GNOME environment, with a focus on implementing multiple language support.
gnome-rust-base can be easily compiled and run using GNOME Builder.
flatpak-builder --user flatpak_app build-aux/org.gnome.Example.json
flatpak-builder --env=LC_ALL=pt_BR.UTF8 --run flatpak_app build-aux/org.gnome.Example.json gnome-rust-base
meson --prefix=/usr build-dir
ninja -C build-dir
ninja -C build-dir install
gnome-rust-base
For detailed information about dependencies, see the Flatpak manifest.
- Creating the
.pot
File:- Build the project with Meson:
meson --prefix=/usr build-dir
- Generate the
.pot
file:ninja -C build/ gnome-rust-base-pot
- The file will be created at
po/gnome-rust-base.pot
.
- Build the project with Meson:
-
UI File Changes:
- In
src/window.ui
, mark properties for translation withtranslatable=yes
.- Example:
<property name="label" translatable="yes">Hello, World!</property>
- Example:
- Update the
.pot
file.
- In
-
Troubleshooting:
- Ensure all commands were executed correctly and that changes to the UI file are correct.
-
Regenerate the
.pot
File:- Command:
ninja -C build gnome-rust-base-pot
.
- Command:
-
Creating Language Files:
- Use
msginit
to generate a translation file for the desired language.- Example:
msginit -l pt_BR --no-translator -i po/gnome-rust-base.pot -o po/pt_BR.po
- Example:
- Translate the
po/pt_BR.po
file using a text editor or specialized tool like gtranslator or poedit.
- Use
-
Updating the
LINGUAS
File:- Add the new language code (e.g.,
pt_BR
) to thepo/LINGUAS
file in alphabetical order. - This step is crucial for the compilation and installation process.
- Add the new language code (e.g.,
- Changing the Application Language:
- The application's language will match the system's
LANG
variable. - To test in a specific language, set the
LC_ALL
variable, e.g.,LC_ALL=pt_BR.UTF8 gnome-rust-base
.
- The application's language will match the system's
Special thanks to Rafael Fontenelle for assisting in understanding how to implement multiple languages in GNOME.