Hello, Following the last mail, you can find attached three patches that add full support for libpeas plugin files support.
libpeas[0] is the GObject Plugin System. It uses plugin files which are a Desktop Entry variant with custom keywords: Name and Description. You can find the definition in the following link: https://git.gnome.org/browse/libpeas/tree/libpeas/peas-plugin-info.c libpeas is the default library chosen for plugins regarding GNOME applications, so those applications would benefit from this patch. Examples of those applications could be: totem[1], gnome-todo[2], gedit[3], etc. The first patch adds plugin file support to xgettext in order to extract translatable strings. The second patch adds plugin file support to msgfmt in order to generate plugin files. Finally, the third patch adds a new example program which uses libpeas as a plugin system and translates plugin files using previous changes, Any suggestions you may have would be greatly appreciated, Best regards, [0] https://wiki.gnome.org/Projects/Libpeas [1] https://wiki.gnome.org/Apps/Videos [2] https://wiki.gnome.org/Apps/Todo [3] https://wiki.gnome.org/Apps/Gedit 2017-06-05 13:42 GMT+02:00 Iñigo Martínez <inigomarti...@gmail.com>: > Hello, > > Recently I have been working on migrating totem[0] from Intltool to a > modern Gettext version[1], but I have faced a problem with libpeas > plugin files[2], which are a Desktop Entry variant[3]. > > While there are different workarounds, libpeas is the default library > choosen for plugins regarding GNOME applications, so I've decided to > solve this problem properly and I've working on its support on > gettext. > > At the moment, I have only added support for extracting text and I > would like to know if my approach is the best way to do it while I > continue working on it. > > You can find attach a patch with those changes. Any suggestion is welcome. > > Best regards, > > [0] https://wiki.gnome.org/Apps/Videos > [1] https://bugzilla.gnome.org/show_bug.cgi?id=783316 > [2] https://bugzilla.gnome.org/show_bug.cgi?id=783316#c10 > [3] https://git.gnome.org/browse/libpeas/tree/libpeas/peas-plugin-info.c
From 4fcef5686c4807721c5e8536db542293ee8d804e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= <inigomarti...@gmail.com> Date: Tue, 6 Jun 2017 11:43:02 +0200 Subject: [PATCH 1/3] Added support for plugin file string extraction in xgettext. * gettext-tools/doc/xgettext.texi: Filled information regarding plugin options. * gettext-tools/src/Makefile.am: Added x-plugin.c and x-plugin.h files. * gettext-tools/src/x-desktop.c: Removed static keyword for extract methods not using static variables that can be shared. * gettext-tools/src/x-desktop.h: Exposed extract methods and the reader structure to be shared among Desktop Entry like files. * gettext-tools/src/x-plugin.c: Support for plugin files. * gettext-tools/src/x-plugin.h: Exposed extract method for plugin files. * gettext-tools/src/xgettext.c: Added support for plugin backend. * tests/Makefile.am: Added xgettext-plugin-1 file. * tests/xgettext-plugin-1: A new test for plugin files based on Desktop test. --- gettext-tools/doc/xgettext.texi | 7 +- gettext-tools/src/Makefile.am | 4 +- gettext-tools/src/x-desktop.c | 14 +--- gettext-tools/src/x-desktop.h | 19 +++++ gettext-tools/src/x-plugin.c | 150 ++++++++++++++++++++++++++++++++++ gettext-tools/src/x-plugin.h | 47 +++++++++++ gettext-tools/src/xgettext.c | 8 +- gettext-tools/tests/Makefile.am | 1 + gettext-tools/tests/xgettext-plugin-1 | 95 +++++++++++++++++++++ 9 files changed, 328 insertions(+), 17 deletions(-) create mode 100644 gettext-tools/src/x-plugin.c create mode 100644 gettext-tools/src/x-plugin.h create mode 100755 gettext-tools/tests/xgettext-plugin-1 diff --git a/gettext-tools/doc/xgettext.texi b/gettext-tools/doc/xgettext.texi index e2700d9f5..84bcb849d 100644 --- a/gettext-tools/doc/xgettext.texi +++ b/gettext-tools/doc/xgettext.texi @@ -74,7 +74,7 @@ are @code{C}, @code{C++}, @code{ObjectiveC}, @code{PO}, @code{Shell}, @code{Smalltalk}, @code{Java}, @code{JavaProperties}, @code{C#}, @code{awk}, @code{YCP}, @code{Tcl}, @code{Perl}, @code{PHP}, @code{GCC-source}, @code{NXStringTable}, @code{RST}, @code{Glade}, @code{Lua}, @code{JavaScript}, -@code{Vala}, @code{GSettings}, @code{Desktop}. +@code{Vala}, @code{GSettings}, @code{Desktop}, @code{Plugin}. @item -C @itemx --c++ @@ -257,7 +257,7 @@ escaped. This option has an effect with most languages, namely C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Java, C#, awk, Tcl, Perl, PHP, -GCC-source, Glade, Lua, JavaScript, Vala, GSettings, Desktop. +GCC-source, Glade, Lua, JavaScript, Vala, GSettings, Desktop, Plugin. The default keyword specifications, which are always looked for if not explicitly disabled, are language dependent. They are: @@ -341,6 +341,9 @@ For Vala: @code{_}, @code{Q_}, @code{N_}, @code{NC_}, @code{dgettext:2}, @item For Desktop: @code{Name}, @code{GenericName}, @code{Comment}, @code{Icon}, @code{Keywords}. + +@item +For Plugin: @code{Name}, @code{Description}. @end itemize To disable the default keyword specifications, the option @samp{-k} or diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index 764afd13a..bf1c7a0df 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -55,7 +55,7 @@ po-time.h plural-table.h lang-table.h format.h filters.h \ xgettext.h x-c.h x-po.h x-sh.h x-python.h x-lisp.h x-elisp.h x-librep.h \ x-scheme.h x-smalltalk.h x-java.h x-properties.h x-csharp.h x-awk.h x-ycp.h \ x-tcl.h x-perl.h x-php.h x-stringtable.h x-rst.h x-glade.h x-lua.h \ -x-javascript.h x-vala.h x-gsettings.h x-desktop.h x-appdata.h +x-javascript.h x-vala.h x-gsettings.h x-desktop.h x-appdata.h x-plugin.h EXTRA_DIST += FILES project-id @@ -180,7 +180,7 @@ xgettext_SOURCES += \ x-c.c x-po.c x-sh.c x-python.c x-lisp.c x-elisp.c x-librep.c x-scheme.c \ x-smalltalk.c x-java.c x-csharp.c x-awk.c x-ycp.c x-tcl.c x-perl.c x-php.c \ x-rst.c x-lua.c x-javascript.c x-vala.c \ - x-desktop.c + x-desktop.c x-plugin.c if !WOE32DLL msgattrib_SOURCES = msgattrib.c else diff --git a/gettext-tools/src/x-desktop.c b/gettext-tools/src/x-desktop.c index 3f382ff50..862965f17 100644 --- a/gettext-tools/src/x-desktop.c +++ b/gettext-tools/src/x-desktop.c @@ -92,15 +92,7 @@ init_keywords (void) } } -typedef struct extract_desktop_reader_ty extract_desktop_reader_ty; -struct extract_desktop_reader_ty -{ - DESKTOP_READER_TY - - message_list_ty *mlp; -}; - -static void +void extract_desktop_handle_group (struct desktop_reader_ty *reader, const char *group) { @@ -131,7 +123,7 @@ extract_desktop_handle_pair (struct desktop_reader_ty *reader, savable_comment_reset (); } -static void +void extract_desktop_handle_comment (struct desktop_reader_ty *reader, const char *buffer) { @@ -153,7 +145,7 @@ extract_desktop_handle_comment (struct desktop_reader_ty *reader, } } -static void +void extract_desktop_handle_blank (struct desktop_reader_ty *reader, const char *s) { diff --git a/gettext-tools/src/x-desktop.h b/gettext-tools/src/x-desktop.h index 4a820e5dd..194277855 100644 --- a/gettext-tools/src/x-desktop.h +++ b/gettext-tools/src/x-desktop.h @@ -20,6 +20,7 @@ #include "message.h" #include "xgettext.h" +#include "read-desktop.h" #ifdef __cplusplus @@ -33,6 +34,15 @@ extern "C" { #define SCANNERS_DESKTOP \ { "Desktop", extract_desktop, NULL, NULL, NULL, NULL }, \ +/* Desktop Entry like file reader. */ +typedef struct extract_desktop_reader_ty extract_desktop_reader_ty; +struct extract_desktop_reader_ty +{ + DESKTOP_READER_TY + + message_list_ty *mlp; +}; + /* Scan a Desktop Entry file and add its translatable strings to mdlp. */ extern void extract_desktop (FILE *fp, const char *real_filename, const char *logical_filename, @@ -41,6 +51,15 @@ extern void extract_desktop (FILE *fp, const char *real_filename, extern void x_desktop_keyword (const char *keyword); +/* Handle Group from a Desktop Entry like file. */ +extern void extract_desktop_handle_group (struct desktop_reader_ty *reader, + const char *group); +/* Handle comments from a Desktop Entry like file. */ +extern void extract_desktop_handle_comment (struct desktop_reader_ty *reader, + const char *buffer); +/* Handle blanks from a Desktop Entry like file. */ +extern void extract_desktop_handle_blank (struct desktop_reader_ty *reader, + const char *s); #ifdef __cplusplus } diff --git a/gettext-tools/src/x-plugin.c b/gettext-tools/src/x-plugin.c new file mode 100644 index 000000000..ca92adefb --- /dev/null +++ b/gettext-tools/src/x-plugin.c @@ -0,0 +1,150 @@ +/* xgettext Desktop Entry backend. + Copyright (C) 2014-2017 Free Software Foundation, Inc. + + This file was written by Iñigo Martínez <inigomarti...@gmail.com>, 2017. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/* Specification. */ +#include "x-plugin.h" +#include "x-desktop.h" + +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "message.h" +#include "xgettext.h" +#include "error.h" +#include "error-progname.h" +#include "xalloc.h" +#include "xvasprintf.h" +#include "hash.h" +#include "gettext.h" +#include "read-desktop.h" +#include "po-charset.h" + +/* ====================== Keyword set customization. ====================== */ + +/* The syntax of libpeas Plugin file is a Desktop Entry variant with a + custom set of keys. It is defined at + https://git.gnome.org/browse/libpeas/tree/libpeas/peas-plugin-info.c + + The syntax of a Desktop Entry file is defined at + http://standards.freedesktop.org/desktop-entry-spec/latest/index.html + + Basically, values with 'localestring' type can be translated. + + The type of a value is determined by looking at the key associated + with it. The list of available keys are listed on: + http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html */ + +static hash_table keywords; +static bool default_keywords = true; + +static void +add_keyword (const char *name, hash_table *keywords, bool is_list) +{ + if (name == NULL) + default_keywords = false; + else + { + if (keywords->table == NULL) + hash_init (keywords, 100); + + desktop_add_keyword (keywords, name, is_list); + } +} + +void +x_plugin_keyword (const char *name) +{ + add_keyword (name, &keywords, false); +} + +static void +init_keywords (void) +{ + if (default_keywords) + { + if (keywords.table == NULL) + hash_init (&keywords, 100); + + desktop_add_keyword (&keywords, "Name", false); + desktop_add_keyword (&keywords, "Description", false); + default_keywords = false; + } +} + +static void +extract_plugin_handle_pair (struct desktop_reader_ty *reader, + lex_pos_ty *key_pos, + const char *key, + const char *locale, + const char *value) +{ + extract_desktop_reader_ty *extract_reader = + (extract_desktop_reader_ty *) reader; + void *keyword_value; + + if (!locale /* Skip already translated entry. */ + && hash_find_entry (&keywords, key, strlen (key), &keyword_value) == 0) + { + bool is_list = (bool) keyword_value; + + remember_a_message (extract_reader->mlp, NULL, + desktop_unescape_string (value, is_list), + null_context, key_pos, + NULL, savable_comment); + } + savable_comment_reset (); +} + +desktop_reader_class_ty extract_plugin_methods = + { + sizeof (extract_desktop_reader_ty), + NULL, + NULL, + extract_desktop_handle_group, + extract_plugin_handle_pair, + extract_desktop_handle_comment, + extract_desktop_handle_blank + }; + +void +extract_plugin (FILE *f, + const char *real_filename, const char *logical_filename, + flag_context_list_table_ty *flag_table, + msgdomain_list_ty *mdlp) +{ + desktop_reader_ty *reader = desktop_reader_alloc (&extract_plugin_methods); + extract_desktop_reader_ty *extract_reader = + (extract_desktop_reader_ty *) reader; + + init_keywords (); + xgettext_current_source_encoding = po_charset_utf8; + + extract_reader->mlp = mdlp->item[0]->messages; + + desktop_parse (reader, f, real_filename, logical_filename); + desktop_reader_free (reader); + + reader = NULL; +} diff --git a/gettext-tools/src/x-plugin.h b/gettext-tools/src/x-plugin.h new file mode 100644 index 000000000..548ba3d30 --- /dev/null +++ b/gettext-tools/src/x-plugin.h @@ -0,0 +1,47 @@ +/* xgettext plugin backend. + Copyright (C) 2014-2017 Free Software Foundation, Inc. + Written by Iñigo Martínez <inigomarti...@gmail.com>, 2017. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + +#include <stdio.h> + +#include "message.h" +#include "xgettext.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +#define EXTENSIONS_PLUGIN \ + { "plugin", "Plugin" }, \ + +#define SCANNERS_PLUGIN \ + { "Plugin", extract_plugin, NULL, NULL, NULL, NULL }, \ + +/* Scan a Plugin file and add its translatable strings to mdlp. */ +extern void extract_plugin (FILE *fp, const char *real_filename, + const char *logical_filename, + flag_context_list_table_ty *flag_table, + msgdomain_list_ty *mdlp); + +extern void x_plugin_keyword (const char *keyword); + + +#ifdef __cplusplus +} +#endif diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index a80ee51ac..5f24dc8ad 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -106,6 +106,7 @@ #include "x-vala.h" #include "x-gsettings.h" #include "x-desktop.h" +#include "x-plugin.h" #define SIZEOF(a) (sizeof(a) / sizeof(a[0])) @@ -487,6 +488,7 @@ main (int argc, char *argv[]) x_javascript_keyword (optarg); x_vala_keyword (optarg); x_desktop_keyword (optarg); + x_plugin_keyword (optarg); if (optarg == NULL) no_default_keywords = true; else @@ -1080,7 +1082,7 @@ Choice of input file language:\n")); EmacsLisp, librep, Scheme, Smalltalk, Java,\n\ JavaProperties, C#, awk, YCP, Tcl, Perl, PHP,\n\ GCC-source, NXStringTable, RST, Glade, Lua,\n\ - JavaScript, Vala, Desktop)\n")); + JavaScript, Vala, Desktop, Plugin)\n")); printf (_("\ -C, --c++ shorthand for --language=C++\n")); printf (_("\ @@ -1130,7 +1132,7 @@ Language specific options:\n")); (only languages C, C++, ObjectiveC, Shell,\n\ Python, Lisp, EmacsLisp, librep, Scheme, Java,\n\ C#, awk, Tcl, Perl, PHP, GCC-source, Glade,\n\ - Lua, JavaScript, Vala, Desktop)\n")); + Lua, JavaScript, Vala, Desktop, Plugin)\n")); printf (_("\ --flag=WORD:ARG:FLAG additional flag for strings inside the argument\n\ number ARG of keyword WORD\n")); @@ -3904,6 +3906,7 @@ language_to_extractor (const char *name) SCANNERS_GSETTINGS SCANNERS_DESKTOP SCANNERS_APPDATA + SCANNERS_PLUGIN /* Here may follow more languages and their scanners: pike, etc... Make sure new scanners honor the --exclude-file option. */ }; @@ -3995,6 +3998,7 @@ extension_to_language (const char *extension) EXTENSIONS_GSETTINGS EXTENSIONS_DESKTOP EXTENSIONS_APPDATA + EXTENSIONS_PLUGIN /* Here may follow more file extensions... */ }; diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 38b47b922..f50509a6a 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -114,6 +114,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \ xgettext-gsettings-1 \ xgettext-desktop-1 \ xgettext-its-1 xgettext-its-2 \ + xgettext-plugin-1 \ format-awk-1 format-awk-2 \ format-boost-1 format-boost-2 \ format-c-1 format-c-2 format-c-3 format-c-4 format-c-5 \ diff --git a/gettext-tools/tests/xgettext-plugin-1 b/gettext-tools/tests/xgettext-plugin-1 new file mode 100755 index 000000000..141488b1b --- /dev/null +++ b/gettext-tools/tests/xgettext-plugin-1 @@ -0,0 +1,95 @@ +#!/bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test of Plugin support. + +: ${XGETTEXT=xgettext} + +cat <<\EOF >err1.plugin +[Plugin] +This is an invalid line +Name =Foo +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err1.plugin 2>&1; exit) | grep "missing '=' after" || Exit 1 + +cat <<\EOF >err2.plugin +[Plugin +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err2.plugin 2>&1; exit) | grep "unterminated group name" || Exit 1 + +cat <<\EOF >err3.plugin +[Plugin] + Not a blank line! +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err3.plugin 2>&1; exit) | grep "invalid non-blank line" || Exit 1 + +cat <<\EOF >err4.plugin +[Plugin]a +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err4.plugin 2>&1; exit) | grep "invalid non-blank character" || Exit 1 + +# gettext 0.19.4 issued an baseless warning of this. +cat <<\EOF >ok4.plugin +[Plugin] +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - ok4.plugin 2>&1; exit) | grep "invalid non-blank character" && Exit 1 + +cat <<\EOF > xg.plugin +[Plugin] +Module=helloworld +Loader=C +Name =Foo +# This is a comment for description +# This is a comment for description +Description= \sThis is a \nmultiline\t description; for testing +Description[foo]=Already translated description +Copyright = Copyright (C) 1995-1998, 2000-2016 Free Software Foundation, Inc. +# This is a comment before a blank line + +Website=https://wiki.gnome.org/Projects/Libpeas +EOF + +${XGETTEXT} --add-comments -o - xg.plugin | grep -v 'POT-Creation-Date' > xg-plugin.pot || Exit 1 + +cat <<\EOF > xg-plugin.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <l...@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: xg.plugin:5 +msgid "Foo" +msgstr "" + +#. This is a comment for description +#. This is a comment for description +#: xg.desktop:8 +msgid "" +" This is a \n" +"multiline\t description; for testing" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-plugin.ok xg-plugin.pot +result=$? + +exit $result -- 2.11.0
From 93ac323c113731e82689e2cbd80ce674dae9a9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= <inigomarti...@gmail.com> Date: Mon, 5 Jun 2017 16:46:36 +0200 Subject: [PATCH 2/3] Added support for plugin file generation with msgfmt. * gettext-tools/doc/msgfmt.texi: Filled information regarding plugin options. * gettext-tools/src/msgfmt.c: Added support for plugin file output. * tests/Makefile.am: Added msgfmt-plugin-1 file. * tests/msgfmt-plugin-1: A new test for plugin files based on Desktop test. --- gettext-tools/doc/msgfmt.texi | 56 ++++++++++++++ gettext-tools/src/msgfmt.c | 144 +++++++++++++++++++++++++++++++++--- gettext-tools/tests/Makefile.am | 1 + gettext-tools/tests/msgfmt-plugin-1 | 82 ++++++++++++++++++++ 4 files changed, 271 insertions(+), 12 deletions(-) create mode 100755 gettext-tools/tests/msgfmt-plugin-1 diff --git a/gettext-tools/doc/msgfmt.texi b/gettext-tools/doc/msgfmt.texi index 90350cb05..5cbf6be7c 100644 --- a/gettext-tools/doc/msgfmt.texi +++ b/gettext-tools/doc/msgfmt.texi @@ -70,6 +70,11 @@ Desktop Entry mode: generate a @file{.desktop} file. @cindex XML mode, and @code{msgfmt} program XML mode: generate an XML file. +@item --plugin +@opindex --plugin@r{, @code{msgfmt} option} +@cindex Plugin mode, and @code{msgfmt} program +Plugin mode: generate a @file{.plugin} file. + @end table @subsection Output file location @@ -272,6 +277,57 @@ variable. For either operation modes, the @samp{-o} and @samp{--template} options are mandatory. +@subsection Plugin mode operations + +@table @samp +@item --template=@var{template} +@opindex --template@r{, @code{msgfmt} option} +Specify a .plugin file used as a template. + +@item -k[@var{keywordspec}] +@itemx --keyword[=@var{keywordspec}] +@opindex -k@r{, @code{msgfmt} option} +@opindex --keyword@r{, @code{msgfmt} option} +Specify @var{keywordspec} as an additional keyword to be looked for. +Without a @var{keywordspec}, the option means to not use default keywords. + +@item -l @var{locale} +@itemx --locale=@var{locale} +@opindex -l@r{, @code{msgfmt} option} +@opindex --locale@r{, @code{msgfmt} option} +Specify the locale name, either a language specification of the form @var{ll} +or a combined language and country specification of the form @var{ll_CC}. + +@item -d @var{directory} +@opindex -d@r{, @code{msgfmt} option} +Specify the directory where PO files are read. The directory must +contain the @samp{LINGUAS} file. + +@end table + +To generate a @samp{.plugin} file for a single locale, you can use it +as follows. + +@example +msgfmt --plugin --template=@var{template} --locale=@var{locale} \ + -o @var{file} @var{filename}.po @dots{} +@end example + +msgfmt provides a special "bulk" operation mode to process multiple +@file{.po} files at a time. + +@example +msgfmt --plugin --template=@var{template} -d @var{directory} -o @var{file} +@end example + +msgfmt first reads the @samp{LINGUAS} file under @var{directory}, and +then processes all @samp{.po} files listed there. You can also limit +the locales to a subset, through the @samp{LINGUAS} environment +variable. + +For either operation modes, the @samp{-o} and @samp{--template} +options are mandatory. + @subsection Input file syntax @table @samp diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index 940121d44..274b058a8 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -125,6 +125,14 @@ static const char *xml_base_directory; static const char *xml_language; static its_rule_list_ty *xml_its_rules; +/* Plugin mode output file specification. */ +static bool plugin_mode; +static const char *plugin_locale_name; +static const char *plugin_template_name; +static const char *plugin_base_directory; +static hash_table plugin_keywords; +static bool plugin_default_keywords = true; + /* We may have more than one input file. Domains with same names in different files have to merged. So we need a list of tables for each output file. */ @@ -199,6 +207,7 @@ static const struct option long_options[] = { "locale", required_argument, NULL, 'l' }, { "no-hash", no_argument, NULL, CHAR_MAX + 6 }, { "output-file", required_argument, NULL, 'o' }, + { "plugin", no_argument, NULL, CHAR_MAX + 17 }, { "properties-input", no_argument, NULL, 'P' }, { "qt", no_argument, NULL, CHAR_MAX + 9 }, { "resource", required_argument, NULL, 'r' }, @@ -303,6 +312,7 @@ main (int argc, char *argv[]) tcl_base_directory = optarg; desktop_base_directory = optarg; xml_base_directory = optarg; + plugin_base_directory = optarg; break; case 'D': dir_list_append (optarg); @@ -318,7 +328,10 @@ main (int argc, char *argv[]) break; case 'k': if (optarg == NULL) - desktop_default_keywords = false; + { + desktop_default_keywords = false; + plugin_default_keywords = false; + } else { if (desktop_keywords.table == NULL) @@ -328,6 +341,14 @@ main (int argc, char *argv[]) } desktop_add_keyword (&desktop_keywords, optarg, false); + + if (plugin_keywords.table == NULL) + { + hash_init (&plugin_keywords, 100); + plugin_default_keywords = false; + } + + desktop_add_keyword (&plugin_keywords, optarg, false); } break; case 'l': @@ -336,6 +357,7 @@ main (int argc, char *argv[]) tcl_locale_name = optarg; desktop_locale_name = optarg; xml_locale_name = optarg; + plugin_locale_name = optarg; break; case 'L': xml_language = optarg; @@ -432,6 +454,10 @@ main (int argc, char *argv[]) case CHAR_MAX + 16: /* --template=TEMPLATE */ desktop_template_name = optarg; xml_template_name = optarg; + plugin_template_name = optarg; + break; + case CHAR_MAX + 17: /* --plugin */ + plugin_mode = true; break; default: usage (EXIT_FAILURE); @@ -460,18 +486,29 @@ There is NO WARRANTY, to the extent permitted by law.\n\ /* Test whether we have a .po file name as argument. */ if (optind >= argc && !(desktop_mode && desktop_base_directory) - && !(xml_mode && xml_base_directory)) + && !(xml_mode && xml_base_directory) + && !(plugin_mode && plugin_base_directory)) { error (EXIT_SUCCESS, 0, _("no input file given")); usage (EXIT_FAILURE); } if (optind < argc && ((desktop_mode && desktop_base_directory) - || (xml_mode && xml_base_directory))) + || (xml_mode && xml_base_directory) + || (plugin_mode && plugin_base_directory))) { + static const char *mode; + + if (desktop_mode) + mode = "--desktop"; + else if (xml_mode) + mode = "--xml"; + else + mode = "--plugin"; + error (EXIT_SUCCESS, 0, _("no input file should be given if %s and %s are specified"), - desktop_mode ? "--desktop" : "--xml", "-d"); + mode, "-d"); usage (EXIT_FAILURE); } @@ -484,10 +521,11 @@ There is NO WARRANTY, to the extent permitted by law.\n\ | (tcl_mode ? 8 : 0) | (qt_mode ? 16 : 0) | (desktop_mode ? 32 : 0) - | (xml_mode ? 64 : 0); + | (xml_mode ? 64 : 0) + | (plugin_mode ? 128 : 0); static const char *mode_options[] = { "--java", "--csharp", "--csharp-resources", "--tcl", "--qt", - "--desktop", "--xml" }; + "--desktop", "--xml", "--plugin" }; /* More than one bit set? */ if (modes & (modes - 1)) { @@ -621,6 +659,34 @@ There is NO WARRANTY, to the extent permitted by law.\n\ usage (EXIT_FAILURE); } } + else if (plugin_mode) + { + if (plugin_template_name == NULL) + { + error (EXIT_SUCCESS, 0, + _("%s requires a \"--template template\" specification"), + "--plugin"); + usage (EXIT_FAILURE); + } + if (output_file_name == NULL) + { + error (EXIT_SUCCESS, 0, + _("%s requires a \"-o file\" specification"), + "--plugin"); + usage (EXIT_FAILURE); + } + if (plugin_base_directory != NULL && plugin_locale_name != NULL) + error (EXIT_FAILURE, 0, + _("%s and %s are mutually exclusive in %s"), + "-d", "-l", "--plugin"); + if (plugin_base_directory == NULL && plugin_locale_name == NULL) + { + error (EXIT_SUCCESS, 0, + _("%s requires a \"-l locale\" specification"), + "--plugin"); + usage (EXIT_FAILURE); + } + } else { if (java_resource_name != NULL) @@ -725,6 +791,27 @@ There is NO WARRANTY, to the extent permitted by law.\n\ exit (exit_status); } + if (plugin_mode && plugin_default_keywords) + { + if (plugin_keywords.table == NULL) + hash_init (&plugin_keywords, 100); + desktop_add_keyword (&plugin_keywords, "Name", false); + desktop_add_keyword (&plugin_keywords, "Description", false); + } + + /* Bulk processing mode for .plugin files. + Process all .po files in plugin_base_directory. */ + if (plugin_mode && plugin_base_directory) + { + exit_status = msgfmt_desktop_bulk (plugin_base_directory, + plugin_template_name, + &plugin_keywords, + output_file_name); + if (plugin_keywords.table != NULL) + hash_destroy (&plugin_keywords); + exit (exit_status); + } + /* The -o option determines the name of the domain and therefore the output file. */ if (output_file_name != NULL) @@ -839,6 +926,18 @@ There is NO WARRANTY, to the extent permitted by law.\n\ domain->file_name)) exit_status = EXIT_FAILURE; } + else if (plugin_mode) + { + if (msgdomain_write_desktop (domain->mlp, canon_encoding, + plugin_locale_name, + plugin_template_name, + &plugin_keywords, + domain->file_name)) + exit_status = EXIT_FAILURE; + + if (plugin_keywords.table != NULL) + hash_destroy (&plugin_keywords); + } else { if (msgdomain_write_mo (domain->mlp, domain->domain_name, @@ -946,6 +1045,8 @@ Operation mode:\n")); --desktop Desktop Entry mode: generate a .desktop file\n")); printf (_("\ --xml XML mode: generate XML file\n")); + printf (_("\ + --plugin Plugin mode: generate a .plugin file\n")); printf ("\n"); printf (_("\ Output file location:\n")); @@ -1028,6 +1129,23 @@ The -l, -o, and --template options are mandatory. If -D is specified, input\n\ files are read from the directory instead of the command line arguments.\n")); printf ("\n"); printf (_("\ +Plugin mode options:\n")); + printf (_("\ + -l, --locale=LOCALE locale name, either language or language_COUNTRY\n")); + printf (_("\ + -o, --output-file=FILE write output to specified file\n")); + printf (_("\ + --template=TEMPLATE a .desktop file used as a template\n")); + printf (_("\ + -d DIRECTORY base directory of .po files\n")); + printf (_("\ + -kWORD, --keyword=WORD look for WORD as an additional keyword\n\ + -k, --keyword do not to use default keywords\n")); + printf (_("\ +The -l, -o, and --template options are mandatory. If -D is specified, input\n\ +files are read from the directory instead of the command line arguments.\n")); + printf ("\n"); + printf (_("\ Input file syntax:\n")); printf (_("\ -P, --properties-input input files are in Java .properties syntax\n")); @@ -1215,7 +1333,8 @@ msgfmt_set_domain (default_catalog_reader_ty *this, char *name) /* If no output file was given, we change it with each 'domain' directive. */ if (!java_mode && !csharp_mode && !csharp_resources_mode && !tcl_mode - && !qt_mode && !desktop_mode && !xml_mode && output_file_name == NULL) + && !qt_mode && !desktop_mode && !xml_mode && plugin_mode + && output_file_name == NULL) { size_t correct; @@ -1638,10 +1757,11 @@ msgfmt_operand_list_add_from_directory (msgfmt_operand_list_ty *operands, return retval; } -/* Helper function to support 'bulk' operation mode of --desktop. - This reads all .po files in DIRECTORY and merges them into a - .desktop file FILE_NAME. Currently it does not support some - options available in 'iterative' mode, such as --statistics. */ +/* Helper function to support 'bulk' operation mode of --desktop + and --plugin. This reads all .po files in DIRECTORY and merges + them into a .desktop or .plugin file FILE_NAME. Currently it + does not support some options available in 'iterative' mode, + such as --statistics. */ static int msgfmt_desktop_bulk (const char *directory, const char *template_file_name, @@ -1661,7 +1781,7 @@ msgfmt_desktop_bulk (const char *directory, return 1; } - /* Write the messages into .desktop file. */ + /* Write the messages into .desktop or .plugin file. */ status = msgdomain_write_desktop_bulk (&operands, template_file_name, keywords, diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index f50509a6a..3a9c2fa36 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -51,6 +51,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \ msgfmt-qt-1 msgfmt-qt-2 \ msgfmt-desktop-1 msgfmt-desktop-2 \ msgfmt-xml-1 msgfmt-xml-2 \ + msgfmt-plugin-1 \ msggrep-1 msggrep-2 msggrep-3 msggrep-4 msggrep-5 msggrep-6 msggrep-7 \ msggrep-8 msggrep-9 msggrep-10 msggrep-11 \ msginit-1 msginit-2 msginit-3 msginit-4 \ diff --git a/gettext-tools/tests/msgfmt-plugin-1 b/gettext-tools/tests/msgfmt-plugin-1 new file mode 100755 index 000000000..4b4221203 --- /dev/null +++ b/gettext-tools/tests/msgfmt-plugin-1 @@ -0,0 +1,82 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test iterative mode of msgfmt --plugin. + +cat <<\EOF > mf.plugin +[Plugin] +Module=helloworld +Depends=foo;bar;baz +Loader=C +Name =Foo +Description[foo]=Already translated description +Description= \sThis is a \nmultiline description; for testing +EOF + +cat <<\EOF > fr.po +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-05 18:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <l...@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: mf.plugin:7 +msgid "Foo" +msgstr "" +"French\n" +"foo" + +#: mf.plugin:9 +msgid "" +" This is a \n" +"multiline description; for testing" +msgstr "" +"French \n" +"description" +EOF + +cat <<\EOF > mf.plugin.ok +[Plugin] +Module=helloworld +Depends=foo;bar;baz +Loader=C +Name[fr]=French\nfoo +Name=Foo +Description[foo]=Already translated description +Description[fr]=French \ndescription +Description=\sThis is a \nmultiline description; for testing +EOF + +# Sanity checks for contradicting options. + +${MSGFMT} --plugin --template=mf.plugin -l fr fr.po \ + >/dev/null 2>/dev/null \ + && Exit 1 + +${MSGFMG} --plugin --template=mf.plugin fr.po -o mf.plugin.out \ + >/dev/null 2>/dev/null \ + && Exit 1 + +# Proceed to the .plugin file generation. + +${MSGFMT} --plugin --template=mf.plugin -l fr fr.po -o mf.plugin.out \ + || Exit 1 + +: ${DIFF=diff} +${DIFF} mf.plugin.ok mf.plugin.out +result=$? + +exit $result -- 2.11.0
From 5a23a36c2d9cf68bd08cf150abfae961e0ee38f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= <inigomarti...@gmail.com> Date: Mon, 5 Jun 2017 22:39:23 +0200 Subject: [PATCH 3/3] Created a new example program for translating plugin files. * gettext-tools/examples/hello-c-plugin: Plugin example using GTK and libpeas. * gettext-tools/examples/Makefile.am: Added hello-c-plugin files. * gettext-tools/examples/README: Listed hello-c-plugin and dependencies. * gettext-tools/examples/po/Makefile.am: Added hello-c-plugin translatable files. --- gettext-tools/examples/Makefile.am | 21 +++ gettext-tools/examples/README | 1 + gettext-tools/examples/hello-c-plugin/INSTALL | 12 ++ gettext-tools/examples/hello-c-plugin/Makefile.am | 62 +++++++++ gettext-tools/examples/hello-c-plugin/autoclean.sh | 73 ++++++++++ gettext-tools/examples/hello-c-plugin/autogen.sh | 31 +++++ gettext-tools/examples/hello-c-plugin/configure.ac | 81 +++++++++++ gettext-tools/examples/hello-c-plugin/hello.c | 150 +++++++++++++++++++++ .../examples/hello-c-plugin/hello.desktop.in.in | 6 + .../examples/hello-c-plugin/hello.gresource.xml | 6 + .../examples/hello-c-plugin/hello.gschema.xml | 11 ++ gettext-tools/examples/hello-c-plugin/hello.ui | 18 +++ .../examples/hello-c-plugin/m4/Makefile.am | 5 + .../examples/hello-c-plugin/plugins/Makefile.am | 1 + .../hello-c-plugin/plugins/hello/Makefile.am | 29 ++++ .../hello-c-plugin/plugins/hello/hello-plugin.c | 129 ++++++++++++++++++ .../hello-c-plugin/plugins/hello/hello-plugin.h | 17 +++ .../hello-c-plugin/plugins/hello/hello.plugin.in | 8 ++ gettext-tools/examples/hello-c-plugin/po/LINGUAS | 5 + gettext-tools/examples/hello-c-plugin/po/Makevars | 67 +++++++++ .../examples/hello-c-plugin/po/POTFILES.in | 9 ++ gettext-tools/examples/po/Makefile.am | 14 ++ 22 files changed, 756 insertions(+) create mode 100644 gettext-tools/examples/hello-c-plugin/INSTALL create mode 100644 gettext-tools/examples/hello-c-plugin/Makefile.am create mode 100755 gettext-tools/examples/hello-c-plugin/autoclean.sh create mode 100755 gettext-tools/examples/hello-c-plugin/autogen.sh create mode 100644 gettext-tools/examples/hello-c-plugin/configure.ac create mode 100644 gettext-tools/examples/hello-c-plugin/hello.c create mode 100644 gettext-tools/examples/hello-c-plugin/hello.desktop.in.in create mode 100644 gettext-tools/examples/hello-c-plugin/hello.gresource.xml create mode 100644 gettext-tools/examples/hello-c-plugin/hello.gschema.xml create mode 100644 gettext-tools/examples/hello-c-plugin/hello.ui create mode 100644 gettext-tools/examples/hello-c-plugin/m4/Makefile.am create mode 100644 gettext-tools/examples/hello-c-plugin/plugins/Makefile.am create mode 100644 gettext-tools/examples/hello-c-plugin/plugins/hello/Makefile.am create mode 100644 gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.c create mode 100644 gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.h create mode 100644 gettext-tools/examples/hello-c-plugin/plugins/hello/hello.plugin.in create mode 100644 gettext-tools/examples/hello-c-plugin/po/LINGUAS create mode 100644 gettext-tools/examples/hello-c-plugin/po/Makevars create mode 100644 gettext-tools/examples/hello-c-plugin/po/POTFILES.in diff --git a/gettext-tools/examples/Makefile.am b/gettext-tools/examples/Makefile.am index a8bcd54be..44ea8f91f 100644 --- a/gettext-tools/examples/Makefile.am +++ b/gettext-tools/examples/Makefile.am @@ -65,6 +65,26 @@ EXAMPLESFILES = \ hello-c-gnome3/po/Makevars \ hello-c-gnome3/po/POTFILES.in \ \ + hello-c-plugin/INSTALL \ + hello-c-plugin/autogen.sh \ + hello-c-plugin/autoclean.sh \ + hello-c-plugin/hello.c \ + hello-c-plugin/hello.desktop.in.in \ + hello-c-plugin/hello.gschema.xml \ + hello-c-plugin/hello.gresource.xml \ + hello-c-plugin/hello.ui \ + hello-c-plugin/Makefile.am \ + hello-c-plugin/configure.ac \ + hello-c-plugin/m4/Makefile.am \ + hello-c-plugin/po/Makevars \ + hello-c-plugin/po/LINGUAS \ + hello-c-plugin/po/POTFILES.in \ + hello-c-plugin/plugins/Makefile.am \ + hello-c-plugin/plugins/hello/hello-plugin.c \ + hello-c-plugin/plugins/hello/hello-plugin.h \ + hello-c-plugin/plugins/hello/hello.plugin.in \ + hello-c-plugin/plugins/hello/Makefile.am \ + \ hello-c++/INSTALL \ hello-c++/autogen.sh \ hello-c++/autoclean.sh \ @@ -376,6 +396,7 @@ EXAMPLESDIRS = \ hello-c \ hello-c-gnome \ hello-c-gnome3 \ + hello-c-plugin \ hello-c++ \ hello-c++-qt \ hello-c++-kde \ diff --git a/gettext-tools/examples/README b/gettext-tools/examples/README index 4eff716d1..061033f6a 100644 --- a/gettext-tools/examples/README +++ b/gettext-tools/examples/README @@ -8,6 +8,7 @@ environment. hello-c C hello-c-gnome C GNOME (obsolete) hello-c-gnome3 C GNOME 3.10 or later + hello-c-plugin C GNOME 3.10 and libpeas 1.0 hello-c++ C++ hello-c++-qt C++ Qt hello-c++-kde C++ KDE diff --git a/gettext-tools/examples/hello-c-plugin/INSTALL b/gettext-tools/examples/hello-c-plugin/INSTALL new file mode 100644 index 000000000..3b9f22fe0 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/INSTALL @@ -0,0 +1,12 @@ +This example relies on: + - the GTK libraries (libgtk, libgdk), version 3.10 or later + - the glib libraries (libglib) + +Installation: + ./autogen.sh + ./configure --prefix=/some/prefix + make + make install +Cleanup: + make distclean + ./autoclean.sh diff --git a/gettext-tools/examples/hello-c-plugin/Makefile.am b/gettext-tools/examples/hello-c-plugin/Makefile.am new file mode 100644 index 000000000..c93e24ed5 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/Makefile.am @@ -0,0 +1,62 @@ +# Example for use of GNU gettext. +# This file is in the public domain. +# +# Makefile configuration - processed by automake. + +# General automake options. +AUTOMAKE_OPTIONS = foreign no-dependencies +ACLOCAL_AMFLAGS = -I m4 + +# The list of subdirectories containing Makefiles. +SUBDIRS = plugins m4 po + +# The list of programs that are built. +bin_PROGRAMS = hello + +# The source files of the 'hello' program. +hello_SOURCES = hello.c resources.c + +# Define a C macro LOCALEDIR indicating where catalogs will be installed. +DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ + +# Make sure the gnome.h include file is found. +AM_CPPFLAGS = $(GTK_CFLAGS) $(PEAS_CFLAGS) $(PEAS_GTK_CFLAGS) + +# Link time dependencies. +LDADD = $(GTK_LIBS) $(PEAS_LIBS) $(PEAS_GTK_LIBS) @LIBINTL@ + +BUILT_SOURCES = gschemas.compiled resources.c + +# Compile GSettings schema. +gschemas.compiled: hello.gschema.xml + $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) . + +# Compile assets into a C source and link it with the application. +resources.c: hello.gresource.xml hello.ui + $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ \ + --sourcedir=$(srcdir) --generate-source + +desktopdir = $(datadir)/applications +desktop_DATA = hello.desktop + +# Merge translations back into a Desktop Entry file. + +# Note that the resulting file should be included in EXTRA_DIST and +# processed earlier than the variable substitution below. Otherwise, +# the 'msgfmt' command will be required at compile-time. +hello.desktop.in: hello.desktop.in.in + $(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ + +# Substitute variables in a Desktop Entry file. +hello.desktop: hello.desktop.in + $(AM_V_GEN) sed -e 's|@bindir[@]|$(bindir)|g' $< > $@ + +CLEANFILES = $(BUILT_SOURCES) hello.desktop $(desktop_DATA) + +# Additional files to be distributed. +EXTRA_DIST = autogen.sh autoclean.sh hello.ui \ + hello.desktop.in.in hello.desktop.in \ + hello.gschema.xml \ + hello.gresource.xml + +MAINTAINERCLEANFILES = hello.desktop.in diff --git a/gettext-tools/examples/hello-c-plugin/autoclean.sh b/gettext-tools/examples/hello-c-plugin/autoclean.sh new file mode 100755 index 000000000..8ea382e1b --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/autoclean.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Example for use of GNU gettext. +# This file is in the public domain. +# +# Script for cleaning all autogenerated files. + +test ! -f Makefile || make distclean + +# Brought in by autopoint. +rm -f ABOUT-NLS +rm -f config.rpath +rm -f m4/codeset.m4 +rm -f m4/gettext.m4 +rm -f m4/glibc2.m4 +rm -f m4/glibc21.m4 +rm -f m4/iconv.m4 +rm -f m4/intdiv0.m4 +rm -f m4/intl.m4 +rm -f m4/intldir.m4 +rm -f m4/intlmacosx.m4 +rm -f m4/intmax.m4 +rm -f m4/inttypes-pri.m4 +rm -f m4/inttypes_h.m4 +rm -f m4/lcmessage.m4 +rm -f m4/lib-ld.m4 +rm -f m4/lib-link.m4 +rm -f m4/lib-prefix.m4 +rm -f m4/lock.m4 +rm -f m4/longlong.m4 +rm -f m4/nls.m4 +rm -f m4/po.m4 +rm -f m4/printf-posix.m4 +rm -f m4/progtest.m4 +rm -f m4/size_max.m4 +rm -f m4/stdint_h.m4 +rm -f m4/uintmax_t.m4 +rm -f m4/visibility.m4 +rm -f m4/wchar_t.m4 +rm -f m4/wint_t.m4 +rm -f m4/xsize.m4 +rm -f po/Makefile.in.in +rm -f po/remove-potcdate.sin + +# Generated by aclocal. +rm -f aclocal.m4 + +# Generated by libtoolize +rm -f compile +rm -f depcomp +rm -f missing +unlink config.guess +unlink config.sub +unlink install-sh +unlink ltmain.sh +unlink m4/libtool.m4 +unlink m4/lt~obsolete.m4 +unlink m4/ltoptions.m4 +unlink m4/ltsugar.m4 +unlink m4/ltversion.m4 + +# Generated by autoconf. +rm -f configure + +# Generated or brought in by automake. +rm -f Makefile.in +rm -f m4/Makefile.in +rm -f install-sh +rm -f missing +rm -f config.guess +rm -f config.sub +rm -f po/*.pot +rm -f po/stamp-po +rm -f po/*.gmo diff --git a/gettext-tools/examples/hello-c-plugin/autogen.sh b/gettext-tools/examples/hello-c-plugin/autogen.sh new file mode 100755 index 000000000..862c80a84 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/autogen.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Example for use of GNU gettext. +# This file is in the public domain. +# +# Script for regenerating all autogenerated files. + +autopoint -f # was: gettextize -f -c +rm po/Makevars.template +rm po/Rules-quot +rm po/boldquot.sed +rm po/en@boldquot.header +rm po/en@quot.header +rm po/insert-header.sin +rm po/quot.sed + +aclocal -I m4 + +libtoolize --verbose --force --install || exit $? + +autoconf + +automake -a -c + +cd po +for f in *.po; do + if test -r "$f"; then + lang=`echo $f | sed -e 's,\.po$,,'` + msgfmt -c -o $lang.gmo $lang.po + fi +done +cd .. diff --git a/gettext-tools/examples/hello-c-plugin/configure.ac b/gettext-tools/examples/hello-c-plugin/configure.ac new file mode 100644 index 000000000..33d6cf344 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/configure.ac @@ -0,0 +1,81 @@ +dnl Example for use of GNU gettext. +dnl This file is in the public domain. +dnl +dnl Configuration file - processed by autoconf. + +AC_INIT +AC_CONFIG_SRCDIR(hello.c) +AM_INIT_AUTOMAKE(hello-c-plugin, 0) + +LT_INIT + +AC_PROG_CC +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION(0.19) + +dnl Check GNOME specific stuff. +dnl +dnl If you have full GNOME development environment installed on your +dnl system, you should be able to use the following macros: +dnl +dnl AM_PATH_GLIB_2_0 +dnl PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.10], , +dnl [AC_MSG_ERROR([can't find gtk+-3.0])]) +dnl +dnl Here, in gettext-tools/examples, we do the checks manually for +dnl simplicity. + +AC_PATH_PROG(GLIB_COMPILE_RESOURCES, [glib-compile-resources]) +AS_IF([test -z "$GLIB_COMPILE_RESOURCES"], [ + AC_MSG_ERROR([can't find glib-compile-resources]) +]) + +AC_PATH_PROG(GLIB_COMPILE_SCHEMAS, [glib-compile-schemas]) +AS_IF([test -z "$GLIB_COMPILE_SCHEMAS"], [ + AC_MSG_ERROR([can't find glib-compile-schemas]) +]) + +AC_PATH_PROG([PKG_CONFIG], [pkg-config]) +AS_IF([test -z "$PKG_CONFIG"], [ + AC_MSG_ERROR([can't find pkg-config]) +]) + +GTK="gtk+-3.0 >= 3.10" +AS_IF(["$PKG_CONFIG" --exists "$GTK"], , [ + AC_MSG_ERROR([can't find $GTK]) +]) + +GTK_CFLAGS=`"$PKG_CONFIG" --cflags "$GTK"` +AC_SUBST(GTK_CFLAGS) + +GTK_LIBS=`"$PKG_CONFIG" --libs "$GTK"` +AC_SUBST(GTK_LIBS) + +PEAS="libpeas-1.0" +AS_IF(["$PKG_CONFIG" --exists "$PEAS"], , [ + AC_MSG_ERROR([can't find $PEAS]) +]) + +PEAS_CFLAGS=`"$PKG_CONFIG" --cflags "$PEAS"` +AC_SUBST(PEAS_CFLAGS) + +PEAS_LIBS=`"$PKG_CONFIG" --libs "$PEAS"` +AC_SUBST(PEAS_LIBS) + +PEAS_GTK="libpeas-gtk-1.0" +AS_IF(["$PKG_CONFIG" --exists "$PEAS_GTK"], , [ + AC_MSG_ERROR([can't find $PEAS_GTK]) +]) + +PEAS_GTK_CFLAGS=`"$PKG_CONFIG" --cflags "$PEAS_GTK"` +AC_SUBST(PEAS_GTK_CFLAGS) + +PEAS_GTK_LIBS=`"$PKG_CONFIG" --libs "$PEAS_GTK"` +AC_SUBST(PEAS_GTK_LIBS) + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([plugins/Makefile]) +AC_CONFIG_FILES([plugins/hello/Makefile]) +AC_CONFIG_FILES([m4/Makefile]) +AC_CONFIG_FILES([po/Makefile.in]) +AC_OUTPUT diff --git a/gettext-tools/examples/hello-c-plugin/hello.c b/gettext-tools/examples/hello-c-plugin/hello.c new file mode 100644 index 000000000..64986d234 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/hello.c @@ -0,0 +1,150 @@ +/* Example for use of GNU gettext. + This file is in the public domain. + + Source code of the C program. */ + + +/* Get GTK declarations. */ +#include <gtk/gtk.h> +#include <glib/gi18n.h> + +/* Get libpeas GTK plugin manager declarations */ +#include <libpeas-gtk/peas-gtk-plugin-manager.h> + +#define UI_PATH "/org/gnu/gettext/examples/hello/hello.ui" +#define APPLICATION_ID "org.gnu.gettext.examples.hello" +#define GSETTINGS_SCHEMA "org.gnu.gettext.examples.hello" + +/* Forward declaration of GObject types. */ + +#define HELLO_TYPE_APPLICATION_WINDOW (hello_application_window_get_type ()) +#define HELLO_APPLICATION_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + HELLO_TYPE_APPLICATION_WINDOW, \ + HelloApplicationWindow)) + +typedef struct _HelloApplicationWindow HelloApplicationWindow; +typedef struct _HelloApplicationWindowClass HelloApplicationWindowClass; + +#define HELLO_TYPE_APPLICATION (hello_application_get_type ()) +#define HELLO_APPLICATION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + HELLO_TYPE_APPLICATION, \ + HelloApplication)) + +typedef struct _HelloApplication HelloApplication; +typedef struct _HelloApplicationClass HelloApplicationClass; + +/* Custom application window implementation. */ + +struct _HelloApplicationWindow +{ + GtkApplicationWindow parent; + GtkWidget *plugin_manager; +}; + +struct _HelloApplicationWindowClass +{ + GtkApplicationWindowClass parent_class; +}; + +G_DEFINE_TYPE (HelloApplicationWindow, hello_application_window, + GTK_TYPE_APPLICATION_WINDOW); + +static void +hello_application_window_init (HelloApplicationWindow *window) +{ + gtk_widget_init_template (GTK_WIDGET (window)); +} + +static void +hello_application_window_class_init (HelloApplicationWindowClass *klass) +{ + g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER); + + gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), + UI_PATH); + gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), + HelloApplicationWindow, plugin_manager); +} + +static HelloApplicationWindow * +hello_application_window_new (HelloApplication *application) +{ + return g_object_new (HELLO_TYPE_APPLICATION_WINDOW, + "application", application, + NULL); +} + +/* Custom application implementation. */ + +struct _HelloApplication +{ + GtkApplication parent; +}; + +struct _HelloApplicationClass +{ + GtkApplicationClass parent_class; +}; + +G_DEFINE_TYPE (HelloApplication, hello_application, GTK_TYPE_APPLICATION); + +static void +hello_application_init (HelloApplication *application) +{ +} + +static void +hello_application_activate (GApplication *application) +{ + HelloApplicationWindow *window; + + window = hello_application_window_new (HELLO_APPLICATION (application)); + + gtk_widget_show_all (GTK_WIDGET (window)); +} + +static void +hello_application_class_init (HelloApplicationClass *klass) +{ + G_APPLICATION_CLASS (klass)->activate = hello_application_activate; +} + +static HelloApplication * +hello_application_new (void) +{ + return g_object_new (HELLO_TYPE_APPLICATION, + "application-id", APPLICATION_ID, + NULL); +} + +int +main (int argc, char *argv[]) +{ + GApplication *application; + PeasEngine *engine; + gchar *plugin_dir; + int status; + + /* Load the GSettings schema from the current directory. */ + g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE); + + /* Initializations. */ + textdomain ("hello-c-plugin"); + bindtextdomain ("hello-c-plugin", LOCALEDIR); + + engine = peas_engine_get_default (); + peas_engine_add_search_path (engine, "plugins", "plugins"); + + /* Create application. */ + application = G_APPLICATION (hello_application_new ()); + + /* Start the application. */ + status = g_application_run (application, argc, argv); + g_object_unref (application); + + g_object_unref (engine); + + return status; +} diff --git a/gettext-tools/examples/hello-c-plugin/hello.desktop.in.in b/gettext-tools/examples/hello-c-plugin/hello.desktop.in.in new file mode 100644 index 000000000..a31bf9337 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/hello.desktop.in.in @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=Hello +Comment=Hello, world! +StartupNotify=true +Exec=@bindir@/hello diff --git a/gettext-tools/examples/hello-c-plugin/hello.gresource.xml b/gettext-tools/examples/hello-c-plugin/hello.gresource.xml new file mode 100644 index 000000000..4d2c27810 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/hello.gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/gnu/gettext/examples/hello"> + <file preprocess="xml-stripblanks">hello.ui</file> + </gresource> +</gresources> diff --git a/gettext-tools/examples/hello-c-plugin/hello.gschema.xml b/gettext-tools/examples/hello-c-plugin/hello.gschema.xml new file mode 100644 index 000000000..d586b5a74 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/hello.gschema.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schemalist> + <schema path="/org/gnu/gettext/examples/hello/" + id="org.gnu.gettext.examples.hello"> + <key name="use-markup" type="b"> + <default>true</default> + <summary>Use XML markup</summary> + <description>Whether to use XML markup in the text.</description> + </key> + </schema> +</schemalist> diff --git a/gettext-tools/examples/hello-c-plugin/hello.ui b/gettext-tools/examples/hello-c-plugin/hello.ui new file mode 100644 index 000000000..7fb7c7e2b --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/hello.ui @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="3.10"/> + <requires lib="libpeas-gtk" version="1.0"/> + <template class="HelloApplicationWindow" parent="GtkApplicationWindow"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">Example Application</property> + <property name="default_width">600</property> + <property name="default_height">400</property> + <child> + <object class="PeasGtkPluginManager" id="plugin_manager"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + </object> + </child> + </template> +</interface> diff --git a/gettext-tools/examples/hello-c-plugin/m4/Makefile.am b/gettext-tools/examples/hello-c-plugin/m4/Makefile.am new file mode 100644 index 000000000..000cd06f0 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/m4/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = \ + codeset.m4 gettext.m4 glibc2.m4 glibc21.m4 iconv.m4 intdiv0.m4 \ + inttypes_h.m4 inttypes-pri.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 \ + lib-prefix.m4 lock.m4 nls.m4 po.m4 progtest.m4 stdint_h.m4 \ + uintmax_t.m4 visibility.m4 diff --git a/gettext-tools/examples/hello-c-plugin/plugins/Makefile.am b/gettext-tools/examples/hello-c-plugin/plugins/Makefile.am new file mode 100644 index 000000000..33042f073 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/plugins/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = hello diff --git a/gettext-tools/examples/hello-c-plugin/plugins/hello/Makefile.am b/gettext-tools/examples/hello-c-plugin/plugins/hello/Makefile.am new file mode 100644 index 000000000..08248c4fa --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/plugins/hello/Makefile.am @@ -0,0 +1,29 @@ +plugindir = $(abs_top_builddir)/plugins/hello + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(PEAS_CFLAGS) \ + $(PEAS_GTK_CFLAGS) + +plugin_LTLIBRARIES = libhello.la + +libhello_la_SOURCES = \ + hello-plugin.h \ + hello-plugin.c + +libhello_la_LDFLAGS = \ + -module \ + -avoid-version \ + -no-undefined + +libhello_la_LIBADD = \ + $(PEAS_LIBS) \ + $(PEAS_GTK_LIBS) + +hello.plugin: hello.plugin.in + $(AM_V_GEN) $(MSGFMT) --plugin --template $< -d $(top_srcdir)/po -o $@ + +plugin_DATA = hello.plugin + +CLEANFILES = $(plugin_DATA) +EXTRA_DIST = hello.plugin.in diff --git a/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.c b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.c new file mode 100644 index 000000000..123a575ef --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.c @@ -0,0 +1,129 @@ +#include <glib-object.h> +#include <libpeas/peas.h> +#include <libpeas-gtk/peas-gtk.h> + +#include "hello-plugin.h" + +struct _HelloPlugin +{ + PeasExtensionBase parent; + + GtkWidget *window; +}; + +static void peas_activatable_iface_init (PeasActivatableInterface *iface); + +G_DEFINE_DYNAMIC_TYPE_EXTENDED (HelloPlugin, + hello_plugin, + PEAS_TYPE_EXTENSION_BASE, + 0, + G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, + peas_activatable_iface_init)) + +enum { + PROP_0, + PROP_OBJECT +}; + +static void +hello_plugin_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + HelloPlugin *plugin = HELLO_PLUGIN (object); + + switch (prop_id) + { + case PROP_OBJECT: + plugin->window = GTK_WIDGET (g_value_dup_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +hello_plugin_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + HelloPlugin *plugin = HELLO_PLUGIN (object); + + switch (prop_id) + { + case PROP_OBJECT: + g_value_set_object (value, plugin->window); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +hello_plugin_init (HelloPlugin *plugin) +{ + g_debug ("%s", G_STRFUNC); +} + +static void +hello_plugin_finalize (GObject *object) +{ + HelloPlugin *plugin = HELLO_PLUGIN (object); + + g_debug ("%s", G_STRFUNC); + + g_object_unref (plugin->window); + + G_OBJECT_CLASS (hello_plugin_parent_class)->finalize (object); +} + +static void +hello_plugin_activate (PeasActivatable *activatable) +{ + g_debug ("%s", G_STRFUNC); +} + +static void +hello_plugin_deactivate (PeasActivatable *activatable) +{ + g_debug ("%s", G_STRFUNC); +} + +static void +hello_plugin_class_init (HelloPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = hello_plugin_set_property; + object_class->get_property = hello_plugin_get_property; + + g_object_class_override_property (object_class, PROP_OBJECT, "object"); +} + +static void +hello_plugin_class_finalize (HelloPluginClass *klass) +{ +} + +static void +peas_activatable_iface_init (PeasActivatableInterface *iface) +{ + iface->activate = hello_plugin_activate; + iface->deactivate = hello_plugin_deactivate; +} + +G_MODULE_EXPORT void +peas_register_types (PeasObjectModule *module) +{ + hello_plugin_register_type (G_TYPE_MODULE (module)); + + peas_object_module_register_extension_type (module, + PEAS_TYPE_ACTIVATABLE, + HELLO_TYPE_PLUGIN); +} diff --git a/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.h b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.h new file mode 100644 index 000000000..d709b29fe --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello-plugin.h @@ -0,0 +1,17 @@ +#ifndef HELLO_PLUGIN_H +#define HELLO_PLUGIN_H + +#include <gtk/gtk.h> +#include <libpeas/peas.h> + +G_BEGIN_DECLS + +#define HELLO_TYPE_PLUGIN (hello_plugin_get_type()) + +G_DECLARE_FINAL_TYPE (HelloPlugin, hello_plugin, HELLO, PLUGIN, PeasExtensionBase) + +G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); + +G_END_DECLS + +#endif /* HELLO_PLUGIN_H */ diff --git a/gettext-tools/examples/hello-c-plugin/plugins/hello/hello.plugin.in b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello.plugin.in new file mode 100644 index 000000000..449f2a1c8 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/plugins/hello/hello.plugin.in @@ -0,0 +1,8 @@ +[Plugin] +Module=hello +Name=Hello Plugin +Description=Hello Plugin for Hello application +Authors=Plugin author +Copyright=Copyright (C) Plugin author +Website=https://www.gnu.org/software/gettext/ +Help=https://www.gnu.org/software/gettext/ diff --git a/gettext-tools/examples/hello-c-plugin/po/LINGUAS b/gettext-tools/examples/hello-c-plugin/po/LINGUAS new file mode 100644 index 000000000..339c7f92f --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/po/LINGUAS @@ -0,0 +1,5 @@ +# Example for use of GNU gettext. +# This file is in the public domain. +# +# Set of available languages. +af ast bg ca cs da de el eo es fi fr ga gl hr hu id it ja ky lv ms mt nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_HK zh_TW diff --git a/gettext-tools/examples/hello-c-plugin/po/Makevars b/gettext-tools/examples/hello-c-plugin/po/Makevars new file mode 100644 index 000000000..7b158ff9b --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/po/Makevars @@ -0,0 +1,67 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = \ + --keyword=_ --flag=_:1:pass-c-format \ + --keyword=N_ --flag=N_:1:pass-c-format \ + --flag=g_log:3:c-format --flag=g_logv:3:c-format \ + --flag=g_error:1:c-format --flag=g_message:1:c-format \ + --flag=g_critical:1:c-format --flag=g_warning:1:c-format \ + --flag=g_print:1:c-format \ + --flag=g_printerr:1:c-format \ + --flag=g_strdup_printf:1:c-format --flag=g_strdup_vprintf:1:c-format \ + --flag=g_printf_string_upper_bound:1:c-format \ + --flag=g_snprintf:3:c-format --flag=g_vsnprintf:3:c-format \ + --flag=g_string_sprintf:2:c-format \ + --flag=g_string_sprintfa:2:c-format \ + --flag=g_scanner_error:2:c-format \ + --flag=g_scanner_warn:2:c-format + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Yoyodyne, Inc. + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = bug-gnu-gett...@gnu.org + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = + +# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' +# context. Possible values are "yes" and "no". Set this to yes if the +# package uses functions taking also a message context, like pgettext(), or +# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. +USE_MSGCTXT = no + +# These options get passed to msgmerge. +# Useful options are in particular: +# --previous to keep previous msgids of translated messages, +# --quiet to reduce the verbosity. +MSGMERGE_OPTIONS = --quiet diff --git a/gettext-tools/examples/hello-c-plugin/po/POTFILES.in b/gettext-tools/examples/hello-c-plugin/po/POTFILES.in new file mode 100644 index 000000000..9fa11da95 --- /dev/null +++ b/gettext-tools/examples/hello-c-plugin/po/POTFILES.in @@ -0,0 +1,9 @@ +# Example for use of GNU gettext. +# This file is in the public domain. +# +# List of files which contain translatable strings. +hello.c +hello.desktop.in.in +hello.ui +hello.gschema.xml +plugins/hello/hello.plugin.in diff --git a/gettext-tools/examples/po/Makefile.am b/gettext-tools/examples/po/Makefile.am index d4f1ad651..49b99016f 100644 --- a/gettext-tools/examples/po/Makefile.am +++ b/gettext-tools/examples/po/Makefile.am @@ -27,6 +27,12 @@ POTFILES = \ hello-c-gnome3/hello.desktop.in.in \ hello-c-gnome3/hello.gschema.xml \ hello-c-gnome3/hello.ui \ + hello-c-plugin/hello.c \ + hello-c-plugin/hello.desktop.in.in \ + hello-c-plugin/hello.gschema.xml \ + hello-c-plugin/hello.ui \ + hello-c-plugin/plugins/hello-plugin.c \ + hello-c-plugin/plugins/hello.plugin.in \ hello-c++/hello.cc \ hello-c++-qt/hello.cc \ hello-c++-kde/hello.cc \ @@ -67,6 +73,7 @@ SMALLPOTS = \ hello-c.pot \ hello-c-gnome.pot \ hello-c-gnome3.pot \ + hello-c-plugin.pot \ hello-c++.pot \ hello-c++-qt.pot \ hello-c++-kde.pot \ @@ -226,6 +233,9 @@ hello-c-gnome.pot : $(POTFILES_DEPS) hello-c-gnome3.pot : $(POTFILES_DEPS) $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-c-gnome3 +hello-c-plugin.pot : $(POTFILES_DEPS) + $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-c-plugin + hello-c++.pot : $(POTFILES_DEPS) $(SHELL) '$(srcdir)/xsmallpot.sh' '$(srcdir)' hello-c++ @@ -386,6 +396,7 @@ SMALLPOFILES_FOR_lang = \ ../hello-c/po/$$lang.po \ ../hello-c-gnome/po/$$lang.po \ ../hello-c-gnome3/po/$$lang.po \ + ../hello-c-plugin/po/$$lang.po \ ../hello-c++/po/$$lang.po \ ../hello-c++-qt/po/$$lang.po \ ../hello-c++-kde/po/$$lang.po \ @@ -423,6 +434,9 @@ SMALLPOFILES_FOR_lang = \ ../hello-c-gnome3/po/$(LL).po: hello-c-gnome3.pot $(LL).po $(SHELL) mmsmallpo.sh hello-c-gnome3 $(LL) +../hello-c-plugin/po/$(LL).po: hello-c-plugin.pot $(LL).po + $(SHELL) mmsmallpo.sh hello-c-plugin $(LL) + ../hello-c++/po/$(LL).po: hello-c++.pot $(LL).po $(SHELL) mmsmallpo.sh hello-c++ $(LL) -- 2.11.0