From 964f1da305d40825535bdfa67e8124c78c80b051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 3 Dec 2021 18:57:59 +0100 Subject: [PATCH] Initialize gettext --- meson.build | 8 ++++++-- po/LINGUAS | 0 po/POTFILES.in | 1 + po/meson.build | 2 ++ src/config.h.in | 6 ++++++ src/server-main.c | 4 ++++ 6 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 po/LINGUAS create mode 100644 po/POTFILES.in create mode 100644 po/meson.build diff --git a/meson.build b/meson.build index 342eccaa..37a3499e 100644 --- a/meson.build +++ b/meson.build @@ -36,8 +36,6 @@ add_project_arguments( i18n = import('i18n') -conf_data = configuration_data() - if get_option('buildtype').startswith('debug') add_project_arguments('-DDEBUG=1', language : 'c') endif @@ -63,6 +61,7 @@ endif prefix = get_option('prefix') bindir = join_paths(prefix, get_option('bindir')) datadir = join_paths(prefix, get_option('datadir')) +localedir = join_paths(prefix, get_option('localedir')) desktopdir = join_paths(datadir, 'applications') pkgdatadir = join_paths(datadir, meson.project_name()) if get_option('depdatadir') == '' @@ -72,6 +71,10 @@ else endif dbusdir = join_paths(depdatadir, 'dbus-1/interfaces') +conf_data = configuration_data() +conf_data.set_quoted('GETTEXT_PACKAGE', 'squeekboard') +conf_data.set_quoted('LOCALEDIR', localedir) + summary = [ '', '------------------', @@ -114,6 +117,7 @@ cargo_script = find_program('cargo.sh') cargo_build = find_program('cargo_build.py') subdir('data') +subdir('po') subdir('protocols') subdir('src') subdir('tools') diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 00000000..e69de29b diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..3641d8d1 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1 @@ +data/popup.ui diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..897abe46 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,2 @@ +i18n = import('i18n') +i18n.gettext('squeekboard', preset : 'glib') diff --git a/src/config.h.in b/src/config.h.in index ae878778..d7afccff 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -2,3 +2,9 @@ * Autogenerated by the Meson build system. * Do not edit, your changes will be lost. */ + +#pragma once + +#mesondefine GETTEXT_PACKAGE + +#mesondefine LOCALEDIR diff --git a/src/server-main.c b/src/server-main.c index 55d2df04..32923e8a 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -326,6 +326,10 @@ main (int argc, char **argv) return 1; } + textdomain (GETTEXT_PACKAGE); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + if (!gtk_init_check (&argc, &argv)) { g_printerr ("Can't init GTK\n"); exit (1);