Skip to content

Commit

Permalink
Add internationalization for this project
Browse files Browse the repository at this point in the history
Finally, install support for gettext so that Meson can be used to
update and compile translation files (.mo). Install the gettext-rs crate
in order to use these translations from the Rust application.

Updates the .blp files to provide some translations to begin with, and
add instructions in regards to how to update the translations in the
README.md file.
  • Loading branch information
danirod committed Mar 28, 2024
1 parent 733d512 commit 397d1d5
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 9 deletions.
156 changes: 156 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
glib = "0.19.3"
gtk4 = "0.8.1"
sourceview5 = "0.8.0"
24 changes: 21 additions & 3 deletions README.md
Expand Up @@ -106,9 +106,27 @@ formatted. Read `hooks/pre-commit.hook` to inspect what the script does.
This project is highly appreciative of contributions. If you know about Rust,
GTK or the GNOME technologies and want to help during the development, you can
contribute if you wish. [Fork the project][fork] and commit your code. **Use a
feature branch, do not make your changes in the trunk branch**. Push to your
fork and send a pull request.
contribute if you wish. [Fork the project][fork] and commit your code.

Some checklist rules before submitting a pull request:

* **Use a feature branch**, do not make your changes in the trunk branch
directly.

* **Rebase your code** and make sure that you are working on top of the most
recent version of the trunk branch, in case something has changed while you
were working on your code.

* **Update the locales** if you changed strings. The ninja target that you are
looking for is called `cartero-update-po` (such as `ninja -C build
cartero-update-po`). Don't worry, you don't have to translate the strings by
yourself, but make sure that the new templates are added to the .po and .pot
files.

* **Use the pre-commit hook**. The pre-commit hook will validate that your code
is formatted. It should be automatically configured if you run Meson in
development mode (`-Dprofile=development`), but you can install it on your
own or run `hooks/pre-commit.hook`.

The project is starting small, so if you want to do something big, it is best
to first start a discussion thread with your proposal in order to see how to
Expand Down
10 changes: 5 additions & 5 deletions data/ui/main_window.blp
Expand Up @@ -44,7 +44,7 @@ template $CarteroWindow: ApplicationWindow {
[end]
Button send {
clicked => $on_send_request() swapped;
label: 'Enviar';
label: _("Send");
}
}

Expand All @@ -56,7 +56,7 @@ template $CarteroWindow: ApplicationWindow {
Notebook {
NotebookPage {
tab: Label {
label: 'Headers';
label: _("Headers");
};

child: ScrolledWindow {
Expand All @@ -71,7 +71,7 @@ template $CarteroWindow: ApplicationWindow {

NotebookPage {
tab: Label {
label: 'Body';
label: _("Body");
};

child: ScrolledWindow {
Expand Down Expand Up @@ -100,7 +100,7 @@ template $CarteroWindow: ApplicationWindow {
Notebook {
NotebookPage {
tab: Label {
label: 'Headers';
label: _("Headers");
};

child: ScrolledWindow {
Expand All @@ -115,7 +115,7 @@ template $CarteroWindow: ApplicationWindow {

NotebookPage {
tab: Label {
label: 'Body';
label: _("Body");
};

child: ScrolledWindow {
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Expand Up @@ -23,6 +23,7 @@ project(
license: 'GPL-3.0-or-later',
)

i18n = import('i18n')
gnome = import('gnome')

base_id = 'es.danirod.Cartero'
Expand All @@ -37,9 +38,11 @@ cargo = find_program('cargo', required: true)
version = meson.project_version()
prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
localedir = prefix / get_option('localedir')

datadir = prefix / get_option('datadir')
pkgdatadir = datadir / meson.project_name()
gettext_package = meson.project_name()

if get_option('profile') == 'development'
profile = 'Devel'
Expand Down Expand Up @@ -69,4 +72,5 @@ if get_option('profile') == 'development'
endif

subdir('data')
subdir('po')
subdir('src')
5 changes: 5 additions & 0 deletions po/LINGUAS
@@ -0,0 +1,5 @@
# Please, keep this file sorted alphabetically.
#
en
es
eo
4 changes: 4 additions & 0 deletions po/POTFILES.in
@@ -0,0 +1,4 @@
# Please, keep this file sorted alphabetically.
#
data/ui/http_header_row.blp
data/ui/main_window.blp
30 changes: 30 additions & 0 deletions po/cartero.pot
@@ -0,0 +1,30 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the cartero package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: cartero\n"
"Report-Msgid-Bugs-To: https://github.com/danirod/cartero/issues\n"
"POT-Creation-Date: 2024-03-28 18:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: data/ui/main_window.blp:47
msgid "Send"
msgstr ""

#: data/ui/main_window.blp:59 data/ui/main_window.blp:103
msgid "Headers"
msgstr ""

#: data/ui/main_window.blp:74 data/ui/main_window.blp:118
msgid "Body"
msgstr ""

0 comments on commit 397d1d5

Please sign in to comment.