From 2164ca1f095dc7d516cad3f471a9b500981c421c Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 17 Nov 2021 09:45:03 +0000 Subject: Vala GUI: initialize gettext --- gen-meson.build | 2 +- meson.am | 2 +- po/disfluid.pot | 6 +++++- po/fr.po | 9 +++++---- src/ui/Makefile.am | 44 ++++++++++++++++++++++++++++++++++++++++++-- src/ui/main.vala | 24 +++++++++++++++++------- 6 files changed, 71 insertions(+), 16 deletions(-) diff --git a/gen-meson.build b/gen-meson.build index 4896fbd..8edeb5f 100755 --- a/gen-meson.build +++ b/gen-meson.build @@ -15,7 +15,7 @@ printf "], language: 'vala')\n" COMMA="" printf "executable('disfluid-gui', files(" -for source in $src_ui_disfluid_gui_SOURCES +for source in $src_ui_disfluid_gui_VALASOURCES do printf "%s'%s'" "$COMMA" "$source" COMMA="," diff --git a/meson.am b/meson.am index 0e8aa31..86422b7 100644 --- a/meson.am +++ b/meson.am @@ -17,5 +17,5 @@ EXTRA_DIST += %reldir%/gen-meson.build meson.build: %reldir%/gen-meson.build config.status - $(AM_V_GEN) PACKAGE="$(PACKAGE)" src_ui_disfluid_gui_SOURCES="$(src_ui_disfluid_gui_SOURCES)" AM_VALAFLAGS="$(AM_VALAFLAGS)" $(SHELL) $< > $@-t + $(AM_V_GEN) PACKAGE="$(PACKAGE)" src_ui_disfluid_gui_VALASOURCES="$(src_ui_disfluid_gui_VALASOURCES)" AM_VALAFLAGS="$(AM_VALAFLAGS)" $(SHELL) $< > $@-t @mv $@-t $@ diff --git a/po/disfluid.pot b/po/disfluid.pot index 3749033..a94e952 100644 --- a/po/disfluid.pot +++ b/po/disfluid.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: disfluid SNAPSHOT\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-11-12 16:47+0100\n" +"POT-Creation-Date: 2021-11-17 12:02+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2118,3 +2118,7 @@ msgstr "" #: src/ui/updated-page.glade:89 msgid "Discard edits" msgstr "" + +#: src/ui/main.vala:32 +msgid "Hello, world!\n" +msgstr "" diff --git a/po/fr.po b/po/fr.po index a79c471..539a36f 100644 --- a/po/fr.po +++ b/po/fr.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc 0.0.0\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-11-12 16:47+0100\n" +"POT-Creation-Date: 2021-11-17 12:02+0100\n" "PO-Revision-Date: 2021-10-20 18:19+0200\n" "Last-Translator: Vivien Kraus \n" "Language-Team: French \n" @@ -2357,6 +2357,10 @@ msgstr "Contenu :" msgid "Discard edits" msgstr "Rejeter les modifications" +#: src/ui/main.vala:32 +msgid "Hello, world!\n" +msgstr "Bonjour, le monde !\n" + #~ msgid "

The authorization request failed

" #~ msgstr "

La requête d’autorisation a échoué

" @@ -3162,9 +3166,6 @@ msgstr "Rejeter les modifications" #~ msgstr "" #~ "le manifeste client est déréférencé depuis ~s, mais il prétend être ~s" -#~ msgid "Hello, world!\n" -#~ msgstr "Bonjour, le monde !\n" - #~ msgid "Hello, world!" #~ msgstr "Bonjour, le monde !" diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am index e66cfe6..623b66d 100644 --- a/src/ui/Makefile.am +++ b/src/ui/Makefile.am @@ -32,19 +32,59 @@ libexec_PROGRAMS += %reldir%/disfluid-gui AM_VALAFLAGS += --pkg=gio-2.0 -%canon_reldir%_disfluid_gui_SOURCES = \ +%canon_reldir%_disfluid_gui_VALASOURCES = \ %reldir%/main.vala \ %reldir%/settings.vala +%canon_reldir%_disfluid_gui_SOURCES = \ + $(%canon_reldir%_disfluid_gui_VALASOURCES:.vala=.c) + %canon_reldir%_disfluid_gui_CFLAGS = \ $(AM_CFLAGS) \ $(GLIB_CFLAGS) \ $(GOBJECT_CFLAGS) \ $(GIO_CFLAGS) \ - -include config.h + -DGETTEXT_PACKAGE=PACKAGE %canon_reldir%_disfluid_gui_LDADD = \ $(GLIB_LIBS) \ $(GOBJECT_LIBS) \ $(GIO_LIBS) \ $(lib_LTLIBRARIES) + +EXTRA_DIST += \ + $(%canon_reldir%_disfluid_gui_VALASOURCES) \ + %reldir%/disfluid-gui-valasources.stamp + +$(srcdir)/%reldir%/disfluid-gui-valasources.stamp: $(%canon_reldir%_disfluid_gui_VALASOURCES) $(dist_vapi_DATA) + $(AM_V_at)rm -f $@ && echo stamp > $@-t + $(AM_V_VALAC)$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS) -C $^ + $(AM_V_at)for source in $^; do case $$source in *.vala) generated=$$(echo "$$source" | sed 's/\.vala$$/.c/'); (echo '#ifdef HAVE_CONFIG_H' ; echo '#include ' echo '#endif' ; cat $$generated) > $$generated-t ; mv $$generated-t $$generated ;; esac done + $(AM_V_at)mv -f $@-t $@ + +## This rule is adapted from the Automake FAQ: +$(%canon_reldir%_disfluid_gui_VALASOURCES:.vala=.c): %reldir%/disfluid-gui-valasources.stamp +## Recover from the removal of $(srcdir)/$@ + @dry=; for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=*|--*);; \ + *n*) dry=:;; \ + esac; \ + done; \ + if test -f $(srcdir)/$@; then :; else \ + $$dry trap 'rm -rf $(srcdir)/%reldir%/disfluid-gui-valasources.lock $<' 1 2 13 15; \ + if $$dry mkdir $(srcdir)/%reldir%/disfluid-gui-valasources.lock 2>/dev/null; then \ +## This code is being executed by the first process. + $$dry rm -f $<; \ + $(MAKE) $(AM_MAKEFLAGS) $<; \ + $$dry rmdir $(srcdir)/%reldir%/disfluid-gui-valasources.lock; \ + else \ +## This code is being executed by the follower processes. +## Wait until the first process is done. + while test -d $(srcdir)/%reldir%/disfluid-gui-valasources.lock && test -z "$$dry"; do \ + sleep 1; \ + done; \ +## Succeed if and only if the first process succeeded. + $$dry test -f $<; exit $$?; \ + fi; \ + fi diff --git a/src/ui/main.vala b/src/ui/main.vala index a0acd6d..82dc9d1 100644 --- a/src/ui/main.vala +++ b/src/ui/main.vala @@ -14,18 +14,28 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +[CCode (cname="PACKAGE")] +extern const string PACKAGE; + +[CCode (cname="LOCALEDIR")] +extern const string LOCALEDIR; + namespace Disfluid { class Main: GLib.Object { public static int main (string[] args) { + GLib.Intl.setlocale (GLib.LocaleCategory.ALL, ""); + GLib.Intl.bindtextdomain (PACKAGE, LOCALEDIR); + GLib.Intl.textdomain (PACKAGE); int return_code = 1; Disfluid.Api.init ((api) => { - var settings = new Disfluid.Settings (api); - foreach (var arg in args) { - stdout.printf ("%s\n", arg); - } - return_code = 0; - return null; - }); + var settings = new Disfluid.Settings (api); + stdout.printf (_ ("Hello, world!\n")); + foreach (var arg in args) { + stdout.printf ("%s\n", arg); + } + return_code = 0; + return null; + }); return return_code; } } -- cgit v1.2.3