aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorTrung Lê <8@tle.id.au>2026-06-10 17:32:15 +1000
committerTrung Lê <8@tle.id.au>2026-06-10 23:21:58 +1000
commite845db5dc4f482f88d1562c0356cd1c65d5f538b (patch)
tree0b1d9ca46ec459667e0a8f2b698e3708e06d84b2 /src/main.c
parentfbd27b7ba04c12eb080ccabec63938c2f05c75ec (diff)
feat: add gettext i18n with translations (vi, de, fr, it, es, pt)
Wire up internationalization for the app and ship six translations. Infrastructure: - meson: import i18n, define GETTEXT_PACKAGE/GSR_LOCALEDIR, add po/ subdir, and translate the .desktop and AppStream metainfo via i18n.merge_file (renamed to .desktop.in / .metainfo.xml.in). - main.c: setlocale + bindtextdomain/textdomain so the catalog is loaded. - po/: LINGUAS, POTFILES.in, meson.build (glib preset). String marking: - Wrap every user-visible string with _() across main.c, gsr-window.c, the four pages and the shortcut dialog (titles, subtitles, labels, buttons, combo display names, notifications, toasts, dialogs, menu items). - Leave ids/keys untranslated: codec/container/service ids, GAction/icon/CSS names, GVariant/format strings, accelerators, etc. Linting: - Re-enable gobject-linter's untranslated_string rule (now that i18n exists) as an error so new user-visible strings must be wrapped. Translations (141 messages each, %s/%d/markup placeholders preserved): - Vietnamese (vi), German (de), French (fr), Italian (it), Spanish (es), Portuguese (pt). Codec names, "OK", proper nouns and the product name are intentionally left in English. Verified: msgfmt --check-format passes and the compiled catalogs resolve (e.g. "Record" -> "Ghi hình" / "Aufnahme" / "Enregistrement").
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index 16e706b..70343d2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,8 @@
+#include <locale.h>
+
#include <adwaita.h>
+#include <glib/gi18n.h>
+
#include "gsr-window.h"
/* ── About dialog ────────────────────────────────────────────────── */
@@ -29,7 +33,7 @@ on_about_action(GSimpleAction *action,
const char *developers[] = { "dec05eba", NULL };
adw_about_dialog_set_developers(about, developers);
- adw_about_dialog_add_credit_section(about, "Adwaita Port",
+ adw_about_dialog_add_credit_section(about, _("Adwaita Port"),
(const char *[]){ "Trung Lê", NULL });
adw_dialog_present(ADW_DIALOG(about), GTK_WIDGET(win));
@@ -52,25 +56,25 @@ on_shortcuts_action(GSimpleAction *action,
adw_shortcuts_dialog_new());
/* ── Stream section ─── */
- AdwShortcutsSection *stream_sec = adw_shortcuts_section_new("Stream");
+ AdwShortcutsSection *stream_sec = adw_shortcuts_section_new(_("Stream"));
adw_shortcuts_section_add(stream_sec,
- adw_shortcuts_item_new("Start / Stop streaming", "<Alt>1"));
+ adw_shortcuts_item_new(_("Start / Stop streaming"), "<Alt>1"));
adw_shortcuts_dialog_add(dialog, stream_sec);
/* ── Record section ─── */
- AdwShortcutsSection *record_sec = adw_shortcuts_section_new("Record");
+ AdwShortcutsSection *record_sec = adw_shortcuts_section_new(_("Record"));
adw_shortcuts_section_add(record_sec,
- adw_shortcuts_item_new("Start / Stop recording", "<Alt>1"));
+ adw_shortcuts_item_new(_("Start / Stop recording"), "<Alt>1"));
adw_shortcuts_section_add(record_sec,
- adw_shortcuts_item_new("Pause / Unpause recording", "<Alt>2"));
+ adw_shortcuts_item_new(_("Pause / Unpause recording"), "<Alt>2"));
adw_shortcuts_dialog_add(dialog, record_sec);
/* ── Replay section ─── */
- AdwShortcutsSection *replay_sec = adw_shortcuts_section_new("Replay");
+ AdwShortcutsSection *replay_sec = adw_shortcuts_section_new(_("Replay"));
adw_shortcuts_section_add(replay_sec,
- adw_shortcuts_item_new("Start / Stop replay", "<Alt>1"));
+ adw_shortcuts_item_new(_("Start / Stop replay"), "<Alt>1"));
adw_shortcuts_section_add(replay_sec,
- adw_shortcuts_item_new("Save replay", "<Alt>2"));
+ adw_shortcuts_item_new(_("Save replay"), "<Alt>2"));
adw_shortcuts_dialog_add(dialog, replay_sec);
adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(win));
@@ -154,6 +158,11 @@ on_activate(GtkApplication *app, gpointer user_data)
int
main(int argc, char *argv[])
{
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, GSR_LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+
g_autoptr(AdwApplication) app = adw_application_new(
"com.dec05eba.gpu_screen_recorder",
G_APPLICATION_DEFAULT_FLAGS);