From d16ced8333aa6c28859d00645f352a705a830c91 Mon Sep 17 00:00:00 2001 From: lenemter Date: Fri, 21 Jul 2023 02:38:51 +0900 Subject: [PATCH 1/2] Correctly setup the locales --- .gitignore | 1 + meson.build | 12 +++++++++++- src/Application.vala | 7 +++++++ src/Config.vala.in | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/Config.vala.in diff --git a/.gitignore b/.gitignore index 5975d974..a937eb8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ build/ +.flatpak-builder/ diff --git a/meson.build b/meson.build index bcce724c..fd985bb6 100644 --- a/meson.build +++ b/meson.build @@ -7,10 +7,20 @@ project( i18n = import('i18n') -add_global_arguments('-DGETTEXT_PACKAGE="captive-login"', '-DGCR_API_SUBJECT_TO_CHANGE', language:'c') +add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), '-DGCR_API_SUBJECT_TO_CHANGE', language:'c') + +config_data = configuration_data() +config_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) +config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +config_file = configure_file( + input: 'src/Config.vala.in', + output: '@BASENAME@', + configuration: config_data +) executable( meson.project_name(), + config_file, 'src/Application.vala', 'src/CaptiveLogin.vala', 'src/CertButton.vala', diff --git a/src/Application.vala b/src/Application.vala index 791924a9..e125601b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -30,6 +30,13 @@ public class Captive.Application : Gtk.Application { settings = new Settings ("io.elementary.desktop.capnet-assist"); } + construct { + Intl.setlocale (LocaleCategory.ALL, ""); + Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + Intl.textdomain (GETTEXT_PACKAGE); + } + public override void activate () { if (!settings.get_boolean ("enabled")) { quit (); diff --git a/src/Config.vala.in b/src/Config.vala.in new file mode 100644 index 00000000..af62dcf7 --- /dev/null +++ b/src/Config.vala.in @@ -0,0 +1,2 @@ +public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@; +public const string LOCALEDIR = @LOCALEDIR@; From b601a042a2c9f14fbe7e097dbb6b9e08a8049c6d Mon Sep 17 00:00:00 2001 From: lenemter Date: Fri, 21 Jul 2023 02:50:52 +0900 Subject: [PATCH 2/2] Revert changing gettext name --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index fd985bb6..d2a74b39 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,7 @@ project( i18n = import('i18n') -add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), '-DGCR_API_SUBJECT_TO_CHANGE', language:'c') +add_global_arguments('-DGETTEXT_PACKAGE="captive-login"', '-DGCR_API_SUBJECT_TO_CHANGE', language:'c') config_data = configuration_data() config_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir'))