Skip to content

Commit

Permalink
fix(i18n): properly set translation domain during layout init
Browse files Browse the repository at this point in the history
Most of the `i18n` boilerplate was there, but the app still needed to
know what domain to look for. This must happen after initialization of
the `GtkBuilder` and before loading the glade file.

The domain is simply the `mo` file packaged with the app and usually
located under:

```
/usr/share/locale/$LANG/LC_MESSAGES/$APP.mo
```

Once again thanks to @maximbaz for pointing it out.

Closes #92
  • Loading branch information
jtheoof committed Feb 21, 2021
1 parent cacb283 commit 5301aeb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 684,10 @@ static bool load_layout(struct swappy_state *state) {

/* Construct a GtkBuilder instance and load our UI description */
GtkBuilder *builder = gtk_builder_new();

// Set translation domain for the application based on `src/po/meson.build`
gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);

if (gtk_builder_add_from_resource(builder, "/me/jtheoof/swappy/swappy.glade",
&error) == 0) {
g_printerr("Error loading file: %s", error->message);
Expand Down

0 comments on commit 5301aeb

Please sign in to comment.