xeme/xeme

Add i18n support

6 months ago, Gary Kramlich
f1473c583272
Parents 5d56028c5da1
Children 78e61564f51e
Add i18n support
--- a/meson.build Fri Dec 01 00:18:15 2023 -0600
+++ b/meson.build Fri Dec 01 00:29:38 2023 -0600
@@ -4,6 +4,11 @@
meson_version : '>=1.0.0',
version : '0.1.0')
+toplevel_inc = include_directories('.')
+
+###############################################################################
+# Versioning
+###############################################################################
parts = meson.project_version().split('-')
if parts.length() > 1
extra = parts[1]
@@ -24,6 +29,9 @@
version_config.set('XEME_EXTRA_VERSION', extra)
version_config.set('XEME_VERSION', meson.project_version())
+###############################################################################
+# Dependencies
+###############################################################################
gnome = import('gnome')
glib_dep = dependency('glib-2.0', version : '>=2.76.0')
gio_dep = dependency('gio-2.0')
@@ -34,15 +42,32 @@
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_76',
language : 'c',)
-toplevel_inc = include_directories('.')
+###############################################################################
+# Internationalization
+###############################################################################
+GETTEXT_PACKAGE = 'xeme'
+LOCALE_DIR = get_option('prefix') / get_option('localedir')
+
+add_project_arguments(f'-DLOCALEDIR="@LOCALE_DIR@"', language : 'c')
+add_project_arguments(f'-DGETTEXT_PACKAGE="@GETTEXT_PACKAGE@"', language : 'c')
+###############################################################################
+# Sub directories
+###############################################################################
subdir('xeme')
+subdir('po')
+###############################################################################
+# Custom Targets
+###############################################################################
if meson.backend() == 'ninja'
run_target('turtles',
- command : ['ninja', '-C', '@BUILD_ROOT@', 'all', 'test'])
+ command : ['ninja', '-C', '@BUILD_ROOT@', 'xeme-pot', 'all', 'test'])
endif
+###############################################################################
+# Summarize all the things!
+###############################################################################
summary({
'prefix': get_option('prefix'),
'bindir': get_option('bindir'),
@@ -51,6 +76,7 @@
}, section : 'Directories')
summary({
+ 'documentation': get_option('doc'),
+ 'internationalization': get_option('nls'),
'introspection': get_option('introspection'),
- 'documentation': get_option('doc'),
}, section : 'Options')
--- a/meson_options.txt Fri Dec 01 00:18:15 2023 -0600
+++ b/meson_options.txt Fri Dec 01 00:29:38 2023 -0600
@@ -9,3 +9,9 @@
type : 'boolean', value : true, yield : true,
description : 'Whether or not to build a GObject Introspection type library'
)
+
+option(
+ 'nls',
+ type : 'boolean', value : true, yield : true,
+ description : 'Install translation files'
+)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/po/POTFILES Fri Dec 01 00:29:38 2023 -0600
@@ -0,0 +1,4 @@
+xeme/xemeinputstream.c
+xeme/xememessage.c
+xeme/xemeoutputstream.c
+xeme/xemestanza.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/po/meson.build Fri Dec 01 00:29:38 2023 -0600
@@ -0,0 +1,11 @@
+if not get_option('nls')
+ summary('translations',
+ 'You have disabled installation of translations which means ' +
+ 'English will be the only available language.',
+ section : 'Warnings')
+
+ subdir_done()
+endif
+
+i18n = import('i18n')
+i18n.gettext(GETTEXT_PACKAGE, preset: 'glib')