From a827b61d637134a763e547abd8ff66408c57564c Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 25 Sep 2018 14:37:03 -0700 Subject: [PATCH] i18n: ensure we setup i18n/l10n during application startup Historically, Sysprof never supported translations. When revamping the Sysprof implementation we didn't fix that, even though we were able to start accepting translations. This ensures we setup the translation tooling at startup. Fixes #3 --- config.h.meson | 36 ------------------------------------ meson.build | 3 ++- src/sp-application.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 config.h.meson diff --git a/config.h.meson b/config.h.meson deleted file mode 100644 index 2d8c8fb4..00000000 --- a/config.h.meson +++ /dev/null @@ -1,36 +0,0 @@ -/* Look for global separate debug info in this path */ -#mesondefine DEBUGDIR - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#mesondefine ENABLE_NLS - -/* GETTEXT package name */ -#mesondefine GETTEXT_PACKAGE - -/* Define if perf supports clockid */ -#mesondefine HAVE_PERF_CLOCKID - -/* Name of package */ -#mesondefine PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#mesondefine PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#mesondefine PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#mesondefine PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#mesondefine PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#mesondefine PACKAGE_URL - -/* Define to the version of this package. */ -#mesondefine PACKAGE_VERSION - -/* Version number of package */ -#mesondefine VERSION diff --git a/meson.build b/meson.build index 217f7825..285d3a3d 100644 --- a/meson.build +++ b/meson.build @@ -29,6 +29,8 @@ config_h.set_quoted('DEBUGDIR', debugdir) config_h.set_quoted('GETTEXT_PACKAGE', 'sysprof') config_h.set10('ENABLE_NLS', true) +config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) +config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR') has_use_clockid = cc.has_member('struct perf_event_attr', 'use_clockid', prefix: '#include ') has_clockid = cc.has_member('struct perf_event_attr', 'clockid', prefix: '#include ') @@ -146,7 +148,6 @@ if cc.has_argument('-fPIE') endif configure_file( - input: 'config.h.meson', output: 'config.h', configuration: config_h ) diff --git a/src/sp-application.c b/src/sp-application.c index 0203ac76..a2892391 100644 --- a/src/sp-application.c +++ b/src/sp-application.c @@ -16,9 +16,7 @@ * along with this program. If not, see . */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include @@ -320,6 +318,14 @@ sp_application_init (SpApplication *self) { "quit", sysprof_quit }, }; + setlocale (LC_ALL, ""); + + bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + g_set_application_name (_("Sysprof")); + g_action_map_add_action_entries (G_ACTION_MAP (self), actions, G_N_ELEMENTS (actions), self); g_application_set_default (G_APPLICATION (self));