traversity/traversity

Add i18n support

15 months ago, Gary Kramlich
a012ecb1c57e
Parents b04c3e1c83f5
Children 4e78a8475ee4
Add i18n support

Testing Done:
ran `ninja libtraveristy-pot` without issue, but nothing was generated as nothing is marked for translation yet.

Reviewed at https://reviews.imfreedom.org/r/2312/
--- a/meson.build Thu Feb 23 22:40:00 2023 -0600
+++ b/meson.build Sun Mar 05 01:53:44 2023 -0600
@@ -40,6 +40,13 @@
version_conf.set('TRAVERSITY_API_VERSION', traversity_soversion)
###############################################################################
+# Gettext
+###############################################################################
+GETTEXT_PACKAGE = meson.project_name()
+find_program('gettext')
+find_program('xgettext')
+
+###############################################################################
# Module imports
###############################################################################
gnome = import('gnome')
@@ -74,6 +81,12 @@
conf.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
conf.set('HAVE_INET_NTOP', cc.has_function('inet_ntop'))
+add_project_arguments([
+ '-DVERSION="@0@"'.format(meson.project_version()),
+ '-DDISPLAY_VERSION="@0@"'.format(meson.project_version()),
+ f'-DGETTEXT_PACKAGE="@GETTEXT_PACKAGE@"'],
+ language : 'c')
+
###############################################################################
# Documentation
###############################################################################
@@ -93,6 +106,7 @@
###############################################################################
# Subdirectories
###############################################################################
+subdir('po')
subdir('traversity')
subdir('traversity-test')
--- a/meson_options.txt Thu Feb 23 22:40:00 2023 -0600
+++ b/meson_options.txt Sun Mar 05 01:53:44 2023 -0600
@@ -3,3 +3,7 @@
option('introspection', type : 'boolean', value : true,
description : 'build introspection data')
+
+option('nls', type : 'boolean', value : true,
+ description : 'Install translation files')
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/po/POTFILES Sun Mar 05 01:53:44 2023 -0600
@@ -0,0 +1,6 @@
+traversity/traversitycore.c
+traversity/traversitycorewin32.c
+traversity/traversityupnpdiscoverer.c
+traversity/traversitycoreunix.c
+traversity/traversitydiscoverer.c
+traversity-test/traversity-test.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/po/meson.build Sun Mar 05 01:53:44 2023 -0600
@@ -0,0 +1,11 @@
+if get_option('nls')
+ i18n = import('i18n')
+
+ i18n.gettext(GETTEXT_PACKAGE, preset: 'glib')
+else
+ summary('translations',
+ 'You have disabled installation of translations which means ' +
+ 'English will be the only available language.',
+ section : 'Warnings')
+endif
+