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
This commit is contained in:
Christian Hergert
2018-09-25 14:37:03 -07:00
parent 0b81a30313
commit a827b61d63
3 changed files with 11 additions and 40 deletions

View File

@ -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

View File

@ -29,6 +29,8 @@ config_h.set_quoted('DEBUGDIR', debugdir)
config_h.set_quoted('GETTEXT_PACKAGE', 'sysprof') config_h.set_quoted('GETTEXT_PACKAGE', 'sysprof')
config_h.set10('ENABLE_NLS', true) 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 <linux/perf_event.h>') has_use_clockid = cc.has_member('struct perf_event_attr', 'use_clockid', prefix: '#include <linux/perf_event.h>')
has_clockid = cc.has_member('struct perf_event_attr', 'clockid', prefix: '#include <linux/perf_event.h>') has_clockid = cc.has_member('struct perf_event_attr', 'clockid', prefix: '#include <linux/perf_event.h>')
@ -146,7 +148,6 @@ if cc.has_argument('-fPIE')
endif endif
configure_file( configure_file(
input: 'config.h.meson',
output: 'config.h', output: 'config.h',
configuration: config_h configuration: config_h
) )

View File

@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef HAVE_CONFIG_H #include "config.h"
# include "config.h"
#endif
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -320,6 +318,14 @@ sp_application_init (SpApplication *self)
{ "quit", sysprof_quit }, { "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_action_map_add_action_entries (G_ACTION_MAP (self), actions, G_N_ELEMENTS (actions), self);
g_application_set_default (G_APPLICATION (self)); g_application_set_default (G_APPLICATION (self));