From e845db5dc4f482f88d1562c0356cd1c65d5f538b Mon Sep 17 00:00:00 2001 From: Trung Lê <8@tle.id.au> Date: Wed, 10 Jun 2026 17:32:15 +1000 Subject: feat: add gettext i18n with translations (vi, de, fr, it, es, pt) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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"). --- meson.build | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 0473058..f10f566 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,10 @@ elif get_option('buildtype') == 'release' add_project_arguments('-DNDEBUG', language : 'c') endif +i18n = import('i18n') +gettext_package = meson.project_name() +localedir = join_paths(get_option('prefix'), get_option('datadir'), 'locale') + src = [ 'src/main.c', 'src/gsr-window.c', @@ -29,6 +33,8 @@ dep = [ c_args = [ '-DGSR_ICONS_PATH="' + join_paths(get_option('prefix'), get_option('datadir'), 'icons') + '"', '-DGSR_VERSION="' + meson.project_version() + '"', + '-DGETTEXT_PACKAGE="' + gettext_package + '"', + '-DGSR_LOCALEDIR="' + localedir + '"', ] if get_option('x11') @@ -56,12 +62,22 @@ executable('gpu-screen-recorder-adw', c_args : c_args, ) -install_data( - files('com.dec05eba.gpu_screen_recorder.desktop'), +subdir('po') + +i18n.merge_file( + input : 'com.dec05eba.gpu_screen_recorder.desktop.in', + output : 'com.dec05eba.gpu_screen_recorder.desktop', + type : 'desktop', + po_dir : 'po', + install : true, install_dir : join_paths(get_option('prefix'), get_option('datadir'), 'applications'), ) -install_data( - files('com.dec05eba.gpu_screen_recorder.metainfo.xml'), +i18n.merge_file( + input : 'com.dec05eba.gpu_screen_recorder.metainfo.xml.in', + output : 'com.dec05eba.gpu_screen_recorder.metainfo.xml', + type : 'xml', + po_dir : 'po', + install : true, install_dir : join_paths(get_option('prefix'), get_option('datadir'), 'metainfo'), ) install_subdir('icons/hicolor', install_dir : join_paths(get_option('prefix'), get_option('datadir'), 'icons')) -- cgit v1.2.3