[gnome-break-timer/dylanmccall/meson-build: 24/25] Fix gettext in settings app



commit ff2f76ba80271995ecb9cacb1ce50d56355a202f
Author: Dylan McCall <dylan dylanmccall com>
Date:   Sat Jan 19 14:52:48 2019 -0800

    Fix gettext in settings app

 README                                      |  5 ++-
 config.vapi                                 |  2 ++
 data/meson.build                            |  8 +++--
 data/org.gnome.BreakTimer.appdata.xml.in.in |  4 +--
 gnome-break-timer.sh.in                     |  4 +--
 meson.build                                 | 48 +++++++++++++----------------
 po/meson.build                              |  5 ++-
 settings/main.vala                          |  5 +++
 8 files changed, 44 insertions(+), 37 deletions(-)
---
diff --git a/README b/README
index 090056a..d75e32f 100644
--- a/README
+++ b/README
@@ -4,8 +4,7 @@ Break Timer
 A break timer application for GNOME.
 
 This helps you to schedule regular breaks. It will remind you to take them
-based on how much you are using the computer. It tries hard to be simple but
-helpful, using notifications to gently indicate when a break has arrived while
-keeping out of the way for activities like games and videos.
+based on how much you are using the computer. It tries to be simple but
+helpful, and it uses notifications to indicate when a break has arrived.
 
 <https://wiki.gnome.org/Apps/GnomeBreakTimer>
diff --git a/config.vapi b/config.vapi
index a254b6f..4b9e749 100644
--- a/config.vapi
+++ b/config.vapi
@@ -1,6 +1,7 @@
 [CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
 namespace Config {
     public const string GETTEXT_PACKAGE;
+    public const string LOCALE_DIR;
     public const string PROJECT_NAME;
     public const string PROJECT_VERSION;
     public const string APPLICATION_ICON;
@@ -11,3 +12,4 @@ namespace Config {
     public const string HELPER_OBJECT_PATH;
     public const string HELPER_BREAK_OBJECT_BASE_PATH;
 }
+
diff --git a/data/meson.build b/data/meson.build
index 9cb23bf..e52d259 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,9 +1,13 @@
 subdir('icons')
 
+data_conf = configuration_data()
+data_conf.set('BINDIR', bindir)
+data_conf.set('SETTINGS_APPLICATION_ID', settings_application_id)
+
 desktop_in_file = configure_file(
     input: 'org.gnome.BreakTimer.desktop.in.in',
     output: 'org.gnome.BreakTimer.desktop.in',
-    configuration: build_conf
+    configuration: data_conf
 )
 
 i18n.merge_file(
@@ -18,7 +22,7 @@ i18n.merge_file(
 appdata_in_file = configure_file(
     input: 'org.gnome.BreakTimer.appdata.xml.in.in',
     output: 'org.gnome.BreakTimer.appdata.xml.in',
-    configuration: build_conf
+    configuration: data_conf
 )
 
 i18n.merge_file(
diff --git a/data/org.gnome.BreakTimer.appdata.xml.in.in b/data/org.gnome.BreakTimer.appdata.xml.in.in
index 1dfd5a5..c85f601 100644
--- a/data/org.gnome.BreakTimer.appdata.xml.in.in
+++ b/data/org.gnome.BreakTimer.appdata.xml.in.in
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <component type="desktop">
-  <id>@SETTINGS_DESKTOP_ID@.desktop</id>
+  <id>@SETTINGS_APPLICATION_ID@.desktop</id>
   <project_license>GPLv3</project_license>
   <name>Break Timer</name>
   <summary>Remember to take regular breaks from using the computer</summary>
@@ -12,4 +12,4 @@
   </screenshots>
   <url type="homepage">https://wiki.gnome.org/GnomeBreakTimer</url>
   <updatecontact>dylan dylanmccall com</updatecontact>
-</component>
\ No newline at end of file
+</component>
diff --git a/gnome-break-timer.sh.in b/gnome-break-timer.sh.in
index 174ba4b..147b3fd 100755
--- a/gnome-break-timer.sh.in
+++ b/gnome-break-timer.sh.in
@@ -8,9 +8,9 @@ else
 fi
 
 if [ "${SUBCOMMAND}" = 'helper' ]; then
-    exec @BINDIR@/gnome-break-timer-service $@
+    exec "@BINDIR@/gnome-break-timer-service" $@
 elif [ "${SUBCOMMAND}" = 'settings' ]; then
-    exec @BINDIR@/gnome-break-timer-settings $@
+    exec "@BINDIR@/gnome-break-timer-settings" $@
 else
     echo "Unknown subcommand '${SUBCOMMAND}'"
 fi
\ No newline at end of file
diff --git a/meson.build b/meson.build
index 02e6e26..9c96892 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,7 @@
-project('gnome-break-timer', 'vala', 'c')
+project('gnome-break-timer', ['vala', 'c'],
+    version: '1.0-dev',
+    license: 'GPL3+'
+)
 
 gnome = import('gnome')
 i18n = import('i18n')
@@ -28,6 +31,7 @@ bindir = join_paths(prefix, get_option('bindir'))
 libdir = join_paths(prefix, get_option('libdir'))
 datadir = join_paths(prefix, get_option('datadir'))
 libexecdir = join_paths(prefix, get_option('libexecdir'))
+locale_dir = join_paths(prefix, get_option('localedir'))
 
 application_icon = 'org.gnome.BreakTimer'
 application_url = 'https://wiki.gnome.org/Apps/BreakTimer'
@@ -38,36 +42,23 @@ helper_object_path = '/org/gnome/BreakTimer'
 helper_break_object_base_path = '/org/gnome/BreakTimer/'
 
 build_conf = configuration_data()
-build_conf.set('BINDIR', bindir)
-build_conf.set('GETTEXT_PACKAGE', gettext_package)
-build_conf.set('PROJECT_NAME', meson.project_name())
-build_conf.set('PROJECT_VERSION', meson.project_version())
-build_conf.set('APPLICATION_ICON', application_icon)
-build_conf.set('APPLICATION_URL', application_url)
-build_conf.set('SETTINGS_APPLICATION_ID', settings_application_id)
-build_conf.set('HELPER_APPLICATION_ID', helper_application_id)
-build_conf.set('HELPER_BUS_NAME', helper_bus_name)
-build_conf.set('HELPER_OBJECT_PATH', helper_object_path)
-build_conf.set('HELPER_BREAK_OBJECT_BASE_PATH', helper_break_object_base_path)
-
-build_conf_quoted = configuration_data()
-build_conf_quoted.set_quoted('BINDIR', bindir)
-build_conf_quoted.set_quoted('GETTEXT_PACKAGE', gettext_package)
-build_conf_quoted.set_quoted('PROJECT_NAME', meson.project_name())
-build_conf_quoted.set_quoted('PROJECT_VERSION', meson.project_version())
-build_conf_quoted.set_quoted('APPLICATION_ICON', application_icon)
-build_conf_quoted.set_quoted('APPLICATION_URL', application_url)
-build_conf_quoted.set_quoted('SETTINGS_APPLICATION_ID', settings_application_id)
-build_conf_quoted.set_quoted('HELPER_APPLICATION_ID', helper_application_id)
-build_conf_quoted.set_quoted('HELPER_BUS_NAME', helper_bus_name)
-build_conf_quoted.set_quoted('HELPER_OBJECT_PATH', helper_object_path)
-build_conf_quoted.set_quoted('HELPER_BREAK_OBJECT_BASE_PATH', helper_break_object_base_path)
+build_conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
+build_conf.set_quoted('LOCALE_DIR', locale_dir)
+build_conf.set_quoted('PROJECT_NAME', meson.project_name())
+build_conf.set_quoted('PROJECT_VERSION', meson.project_version())
+build_conf.set_quoted('APPLICATION_ICON', application_icon)
+build_conf.set_quoted('APPLICATION_URL', application_url)
+build_conf.set_quoted('SETTINGS_APPLICATION_ID', settings_application_id)
+build_conf.set_quoted('HELPER_APPLICATION_ID', helper_application_id)
+build_conf.set_quoted('HELPER_BUS_NAME', helper_bus_name)
+build_conf.set_quoted('HELPER_OBJECT_PATH', helper_object_path)
+build_conf.set_quoted('HELPER_BREAK_OBJECT_BASE_PATH', helper_break_object_base_path)
 
 add_project_arguments('-DGETTEXT_PACKAGE="' + gettext_package + '"', language: 'c')
 
 configure_file(
     output: 'config.h',
-    configuration: build_conf_quoted
+    configuration: build_conf
 )
 
 config_lib = valac.find_library(
@@ -80,10 +71,13 @@ config_lib_dep = declare_dependency(
     include_directories: include_directories('.')
 )
 
+run_script_conf = configuration_data()
+run_script_conf.set('BINDIR', bindir)
+
 configure_file(
     input: 'gnome-break-timer.sh.in',
     output: 'gnome-break-timer',
-    configuration: build_conf,
+    configuration: run_script_conf,
     install: true,
     install_dir: bindir
 )
diff --git a/po/meson.build b/po/meson.build
index 6a87565..11afc13 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -1 +1,4 @@
-i18n.gettext(gettext_package, preset: 'glib')
\ No newline at end of file
+i18n.gettext(
+    gettext_package,
+    preset: 'glib'
+)
\ No newline at end of file
diff --git a/settings/main.vala b/settings/main.vala
index 34a4490..07c6151 100644
--- a/settings/main.vala
+++ b/settings/main.vala
@@ -18,6 +18,11 @@
 namespace BreakTimer.Settings {
 
 public int main (string[] args) {
+    Intl.setlocale (LocaleCategory.ALL, "");
+    Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALE_DIR);
+    Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
+    Intl.textdomain (Config.GETTEXT_PACKAGE);
+
     SettingsApplication application = new SettingsApplication ();
     int status = application.run (args);
     return status;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]