Update upstream source from tag 'upstream/0.7.0'
Update to upstream version '0.7.0'
with Debian dir 5b9bba35092f88d18584608c7168f0ce4b376fd1
Sascha Steinbiss
4 years ago
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: BabelGladeExtractor |
2 | Version: 0.6.3 | |
3 | Summary: Babel Glade XML files translatable strings extractor | |
2 | Version: 0.7.0 | |
3 | Summary: Babel l10n support for Glade, GtkBuilder, and .desktop files | |
4 | 4 | Home-page: https://github.com/GNOME-Keysign/babel-glade |
5 | 5 | Author: Pedro Algarvio |
6 | 6 | Author-email: ufs@ufsoft.org |
7 | 7 | Maintainer: Tobias Mueller |
8 | 8 | Maintainer-email: tobiasmue@gnome.org |
9 | 9 | License: BSD |
10 | Description: UNKNOWN | |
11 | Keywords: PyGTK,Glade,gettext,Babel,I18n,L10n | |
10 | Description: # BabelGladeExtractor | |
11 | ||
12 | This package contains message catalog extractors for the following | |
13 | formats, extending [Babel][babel] so it can handle them. | |
14 | ||
15 | * The new XML format used by [Glade][glade] 3.8 and above, properly | |
16 | known as the [GtkBuilder UI Definitions][uixml] format; | |
17 | ||
18 | * The older "GladeXML" format used by libglade and older versions of | |
19 | Glade; | |
20 | ||
21 | * The GNOME [AppData XML][appdataxml] dialect, because it's similar; | |
22 | ||
23 | * FreeDesktop.org [Desktop Entry][desktopfile] files. | |
24 | ||
25 | ## Getting started | |
26 | ||
27 | To make these formats translatable, install this package using pip: | |
28 | ||
29 | ```shell | |
30 | pip3 install BabelGladeExtractor | |
31 | ``` | |
32 | ||
33 | Then in your own projects, map some source and data files to the simple | |
34 | extractor names "glade" and "desktop" that are provided by this package. | |
35 | In your `setup.py`, add a section like | |
36 | ||
37 | ```ini | |
38 | [extract_messages] | |
39 | mapping_file = babel.cfg | |
40 | output_file = subdir/myproject.pot | |
41 | input_dirs = . | |
42 | ``` | |
43 | ||
44 | Next, create a separate `babel.cfg` file, and add sections to it for | |
45 | each format you want to translate. | |
46 | ||
47 | ```ini | |
48 | [glade: **.ui] | |
49 | ||
50 | [desktop: **.desktop] | |
51 | ||
52 | ``` | |
53 | ||
54 | You can then use Babel's [setuptools integration][babelsetuptools] or | |
55 | its [command line interface][babelcli] for your routine i18n lifecycle | |
56 | tasks. | |
57 | ||
58 | ```shell | |
59 | python3 setup.py extract_messages | |
60 | ``` | |
61 | ||
62 | There's a lot more to it than this, naturally. See Babel's extensive | |
63 | [Working with Message Catalogs][babelpo] documentation for a detailed | |
64 | explanation of how to get translatable strings into your Python code. | |
65 | ||
66 | In Glade 3.22, when you are editing a string property in a sidebar, | |
67 | click the edit icon on the right hand side of the text entry. In the | |
68 | dialog that pops up, enter the text in the main text box, and make sure | |
69 | that the Translatable checkbox is ticked. You can also add some helpful | |
70 | [context][pocontext] or comments for your translators if you need to | |
71 | give them a hint. BabelGladeExtractor will handle the corresponding XML | |
72 | attributes appropriately when it extracts strings for translation. | |
73 | ||
74 | [babel]: http://babel.pocoo.org/ | |
75 | [glade]: https://glade.gnome.org/ | |
76 | [uixml]: https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI | |
77 | [appdataxml]: https://wiki.gnome.org/Initiatives/GnomeGoals/AppDataGnomeSoftware | |
78 | [desktopfile]: https://specifications.freedesktop.org/desktop-entry-spec/ | |
79 | [babelsetuptools]: http://babel.pocoo.org/en/latest/setup.html | |
80 | [babelcli]: http://babel.pocoo.org/en/latest/cmdline.html | |
81 | [babelpo]: http://babel.pocoo.org/en/latest/messages.html | |
82 | [pocontext]: https://www.gnu.org/software/gettext/manual/html_node/Contexts.html#Contexts | |
83 | ||
84 | Keywords: PyGTK,PyGObject,Glade,GtkBuilder,gettext,Babel,I18n,L10n | |
12 | 85 | Platform: UNKNOWN |
86 | Description-Content-Type: text/markdown |
0 | 0 | MANIFEST.in |
1 | README.md | |
1 | 2 | setup.cfg |
2 | 3 | setup.py |
3 | 4 | BabelGladeExtractor.egg-info/PKG-INFO |
12 | 13 | babelglade/tests/__init__.py |
13 | 14 | babelglade/tests/test.raw.appdata.xml |
14 | 15 | babelglade/tests/test.raw.desktop |
16 | babelglade/tests/test_extract.glade2.xml | |
17 | babelglade/tests/test_extract.gtkbuilder.xml | |
15 | 18 | babelglade/tests/test_extract.py |
16 | 19 | babelglade/tests/test_translate.py |
17 | 20 | babelglade/tests/locale/fr/LC_MESSAGES/test.po |
0 | 0 | include babelglade/tests/test.raw.* |
1 | include babelglade/tests/test_extract.* | |
1 | 2 | recursive-include babelglade/tests/locale * |
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: BabelGladeExtractor |
2 | Version: 0.6.3 | |
3 | Summary: Babel Glade XML files translatable strings extractor | |
2 | Version: 0.7.0 | |
3 | Summary: Babel l10n support for Glade, GtkBuilder, and .desktop files | |
4 | 4 | Home-page: https://github.com/GNOME-Keysign/babel-glade |
5 | 5 | Author: Pedro Algarvio |
6 | 6 | Author-email: ufs@ufsoft.org |
7 | 7 | Maintainer: Tobias Mueller |
8 | 8 | Maintainer-email: tobiasmue@gnome.org |
9 | 9 | License: BSD |
10 | Description: UNKNOWN | |
11 | Keywords: PyGTK,Glade,gettext,Babel,I18n,L10n | |
10 | Description: # BabelGladeExtractor | |
11 | ||
12 | This package contains message catalog extractors for the following | |
13 | formats, extending [Babel][babel] so it can handle them. | |
14 | ||
15 | * The new XML format used by [Glade][glade] 3.8 and above, properly | |
16 | known as the [GtkBuilder UI Definitions][uixml] format; | |
17 | ||
18 | * The older "GladeXML" format used by libglade and older versions of | |
19 | Glade; | |
20 | ||
21 | * The GNOME [AppData XML][appdataxml] dialect, because it's similar; | |
22 | ||
23 | * FreeDesktop.org [Desktop Entry][desktopfile] files. | |
24 | ||
25 | ## Getting started | |
26 | ||
27 | To make these formats translatable, install this package using pip: | |
28 | ||
29 | ```shell | |
30 | pip3 install BabelGladeExtractor | |
31 | ``` | |
32 | ||
33 | Then in your own projects, map some source and data files to the simple | |
34 | extractor names "glade" and "desktop" that are provided by this package. | |
35 | In your `setup.py`, add a section like | |
36 | ||
37 | ```ini | |
38 | [extract_messages] | |
39 | mapping_file = babel.cfg | |
40 | output_file = subdir/myproject.pot | |
41 | input_dirs = . | |
42 | ``` | |
43 | ||
44 | Next, create a separate `babel.cfg` file, and add sections to it for | |
45 | each format you want to translate. | |
46 | ||
47 | ```ini | |
48 | [glade: **.ui] | |
49 | ||
50 | [desktop: **.desktop] | |
51 | ||
52 | ``` | |
53 | ||
54 | You can then use Babel's [setuptools integration][babelsetuptools] or | |
55 | its [command line interface][babelcli] for your routine i18n lifecycle | |
56 | tasks. | |
57 | ||
58 | ```shell | |
59 | python3 setup.py extract_messages | |
60 | ``` | |
61 | ||
62 | There's a lot more to it than this, naturally. See Babel's extensive | |
63 | [Working with Message Catalogs][babelpo] documentation for a detailed | |
64 | explanation of how to get translatable strings into your Python code. | |
65 | ||
66 | In Glade 3.22, when you are editing a string property in a sidebar, | |
67 | click the edit icon on the right hand side of the text entry. In the | |
68 | dialog that pops up, enter the text in the main text box, and make sure | |
69 | that the Translatable checkbox is ticked. You can also add some helpful | |
70 | [context][pocontext] or comments for your translators if you need to | |
71 | give them a hint. BabelGladeExtractor will handle the corresponding XML | |
72 | attributes appropriately when it extracts strings for translation. | |
73 | ||
74 | [babel]: http://babel.pocoo.org/ | |
75 | [glade]: https://glade.gnome.org/ | |
76 | [uixml]: https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI | |
77 | [appdataxml]: https://wiki.gnome.org/Initiatives/GnomeGoals/AppDataGnomeSoftware | |
78 | [desktopfile]: https://specifications.freedesktop.org/desktop-entry-spec/ | |
79 | [babelsetuptools]: http://babel.pocoo.org/en/latest/setup.html | |
80 | [babelcli]: http://babel.pocoo.org/en/latest/cmdline.html | |
81 | [babelpo]: http://babel.pocoo.org/en/latest/messages.html | |
82 | [pocontext]: https://www.gnu.org/software/gettext/manual/html_node/Contexts.html#Contexts | |
83 | ||
84 | Keywords: PyGTK,PyGObject,Glade,GtkBuilder,gettext,Babel,I18n,L10n | |
12 | 85 | Platform: UNKNOWN |
86 | Description-Content-Type: text/markdown |
0 | # BabelGladeExtractor | |
1 | ||
2 | This package contains message catalog extractors for the following | |
3 | formats, extending [Babel][babel] so it can handle them. | |
4 | ||
5 | * The new XML format used by [Glade][glade] 3.8 and above, properly | |
6 | known as the [GtkBuilder UI Definitions][uixml] format; | |
7 | ||
8 | * The older "GladeXML" format used by libglade and older versions of | |
9 | Glade; | |
10 | ||
11 | * The GNOME [AppData XML][appdataxml] dialect, because it's similar; | |
12 | ||
13 | * FreeDesktop.org [Desktop Entry][desktopfile] files. | |
14 | ||
15 | ## Getting started | |
16 | ||
17 | To make these formats translatable, install this package using pip: | |
18 | ||
19 | ```shell | |
20 | pip3 install BabelGladeExtractor | |
21 | ``` | |
22 | ||
23 | Then in your own projects, map some source and data files to the simple | |
24 | extractor names "glade" and "desktop" that are provided by this package. | |
25 | In your `setup.py`, add a section like | |
26 | ||
27 | ```ini | |
28 | [extract_messages] | |
29 | mapping_file = babel.cfg | |
30 | output_file = subdir/myproject.pot | |
31 | input_dirs = . | |
32 | ``` | |
33 | ||
34 | Next, create a separate `babel.cfg` file, and add sections to it for | |
35 | each format you want to translate. | |
36 | ||
37 | ```ini | |
38 | [glade: **.ui] | |
39 | ||
40 | [desktop: **.desktop] | |
41 | ||
42 | ``` | |
43 | ||
44 | You can then use Babel's [setuptools integration][babelsetuptools] or | |
45 | its [command line interface][babelcli] for your routine i18n lifecycle | |
46 | tasks. | |
47 | ||
48 | ```shell | |
49 | python3 setup.py extract_messages | |
50 | ``` | |
51 | ||
52 | There's a lot more to it than this, naturally. See Babel's extensive | |
53 | [Working with Message Catalogs][babelpo] documentation for a detailed | |
54 | explanation of how to get translatable strings into your Python code. | |
55 | ||
56 | In Glade 3.22, when you are editing a string property in a sidebar, | |
57 | click the edit icon on the right hand side of the text entry. In the | |
58 | dialog that pops up, enter the text in the main text box, and make sure | |
59 | that the Translatable checkbox is ticked. You can also add some helpful | |
60 | [context][pocontext] or comments for your translators if you need to | |
61 | give them a hint. BabelGladeExtractor will handle the corresponding XML | |
62 | attributes appropriately when it extracts strings for translation. | |
63 | ||
64 | [babel]: http://babel.pocoo.org/ | |
65 | [glade]: https://glade.gnome.org/ | |
66 | [uixml]: https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI | |
67 | [appdataxml]: https://wiki.gnome.org/Initiatives/GnomeGoals/AppDataGnomeSoftware | |
68 | [desktopfile]: https://specifications.freedesktop.org/desktop-entry-spec/ | |
69 | [babelsetuptools]: http://babel.pocoo.org/en/latest/setup.html | |
70 | [babelcli]: http://babel.pocoo.org/en/latest/cmdline.html | |
71 | [babelpo]: http://babel.pocoo.org/en/latest/messages.html | |
72 | [pocontext]: https://www.gnu.org/software/gettext/manual/html_node/Contexts.html#Contexts |
13 | 13 | # ============================================================================= |
14 | 14 | from __future__ import unicode_literals |
15 | 15 | |
16 | import sys | |
17 | ||
18 | 16 | import xml.etree.ElementTree as etree |
19 | 17 | |
18 | ||
20 | 19 | def extract_glade(fileobj, keywords, comment_tags, options): |
21 | tree = etree.parse(fileobj) | |
22 | root = tree.getroot() | |
23 | to_translate = [] | |
24 | for elem in root.iter(): | |
25 | # do we need to check if the element starts with "gtk-"? | |
26 | if elem.get("translatable") == "yes": | |
27 | line_no = 0 | |
20 | """Extracts translatable strings from Glade files or GtkBuilder UI XML. | |
21 | ||
22 | :param fileobj: the file-like object to extract from, iterable by lines | |
23 | :param keywords: a list of translation keywords to extract, with the same | |
24 | names and meanings as C/Python i18n function names. | |
25 | :param comment_tags: a list of translator tags to search for and | |
26 | include in the results. This is ignored. | |
27 | :param options: a dictionary of additional options (optional) | |
28 | :return: An iterator over ``(lineno, funcname, message, comments)`` | |
29 | tuples whose interpretation depends on ``funcname``. | |
30 | :rtype: iterator | |
31 | ||
32 | Properties must be marked translatable="yes". The "context" and | |
33 | "comments" attributes are respected. The yielded tuples are returned | |
34 | as if you used ``gettext()`` or ``pgettext()`` in C or Python code. | |
35 | This means that translatable XML strings with contexts are are only | |
36 | extracted if the string ``"pgettext"`` is present in ``keywords``, | |
37 | and XML strings without context are only extracted if ``"gettext"`` | |
38 | is present. The shorthand ``_`` and ``C_`` aliases from ``g18n.h`` | |
39 | are valid ``keywords`` too. | |
40 | ||
41 | By default, Babel passes both these function names in ``keywords``, | |
42 | amongst others, so you don't normally need to worry about this. | |
43 | ||
44 | See also: | |
45 | ||
46 | * babel.messages.extract.extract() | |
47 | * http://babel.pocoo.org/en/latest/messages.html#writing-extraction-methods | |
48 | * https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html | |
49 | ||
50 | """ | |
51 | parser = etree.XMLPullParser(["end"]) | |
52 | pgettext_wanted = ("pgettext" in keywords) or ("C_" in keywords) | |
53 | gettext_wanted = "gettext" in keywords | |
54 | truthy_values = [s.casefold() for s in ["yes", "true", "1", "y", "t"]] | |
55 | for line_idx, line_data in enumerate(fileobj): | |
56 | parser.feed(line_data) | |
57 | for event, elem in parser.read_events(): | |
58 | assert event == "end" | |
59 | translatable_attr = elem.attrib.get("translatable", "no") | |
60 | if not translatable_attr.casefold() in truthy_values: | |
61 | continue | |
62 | ||
63 | comments = [] | |
64 | if "comments" in elem.attrib: | |
65 | comments.append(elem.attrib["comments"]) | |
66 | ||
67 | # Babel's interpretation of the yielded tuple depends on the | |
68 | # function name returned as part of it. This tells Babel what | |
69 | # the elements of the returned messages list or tuple mean. | |
28 | 70 | func_name = None |
29 | message = elem.text | |
30 | comment = [] | |
31 | if elem.get("comments"): | |
32 | comment = [elem.get("comments")] | |
33 | to_translate.append([line_no, func_name, message, comment]) | |
34 | return to_translate | |
71 | if "context" in elem.attrib and pgettext_wanted: | |
72 | func_name = "pgettext" | |
73 | context = elem.attrib["context"] | |
74 | messages = [context, elem.text] | |
75 | elif gettext_wanted and "context" not in elem.attrib: | |
76 | # Returned strings are equivalent to a list or tuple | |
77 | # of length 1, like the arguments to C gettext()/_(). | |
78 | func_name = "gettext" | |
79 | messages = elem.text | |
80 | ||
81 | if func_name is None: | |
82 | continue | |
83 | yield (line_idx + 1, func_name, messages, comments) | |
35 | 84 | |
36 | 85 | |
37 | 86 | # All localestrings from https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s05.html |
0 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
1 | <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> | |
2 | <glade-interface> | |
3 | <widget class="GtkWindow" id="window1"> | |
4 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
5 | <child> | |
6 | <widget class="GtkVBox" id="vbox1"> | |
7 | <property name="visible">True</property> | |
8 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
9 | <child> | |
10 | <widget class="GtkLabel" id="label1"> | |
11 | <property name="visible">True</property> | |
12 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
13 | <property name="label" translatable="yes" comments="A label with translator comments">This is a Label</property> | |
14 | </widget> | |
15 | </child> | |
16 | <child> | |
17 | <widget class="GtkButton" id="button1"> | |
18 | <property name="visible">True</property> | |
19 | <property name="can_focus">True</property> | |
20 | <property name="receives_default">True</property> | |
21 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
22 | <property name="label" translatable="yes" comments="This button also includes translator comments">A button</property> | |
23 | </widget> | |
24 | <packing> | |
25 | <property name="position">1</property> | |
26 | </packing> | |
27 | </child> | |
28 | </widget> | |
29 | </child> | |
30 | </widget> | |
31 | </glade-interface> |
0 | <?xml version="1.0" encoding="UTF-8"?> | |
1 | <!-- Generated with glade 3.22.1 --> | |
2 | <interface> | |
3 | <requires lib="gtk+" version="3.20"/> | |
4 | <object class="GtkWindow" id="window1"> | |
5 | <property name="can_focus">False</property> | |
6 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
7 | <child> | |
8 | <placeholder/> | |
9 | </child> | |
10 | <child> | |
11 | <object class="GtkVBox" id="vbox1"> | |
12 | <property name="visible">True</property> | |
13 | <property name="can_focus">False</property> | |
14 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
15 | <child> | |
16 | <object class="GtkLabel" id="label1"> | |
17 | <property name="visible">True</property> | |
18 | <property name="can_focus">False</property> | |
19 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
20 | <property name="label" translatable="yes" context="the first label" comments="A label with translator comments">This is a Label</property> | |
21 | </object> | |
22 | <packing> | |
23 | <property name="expand">True</property> | |
24 | <property name="fill">True</property> | |
25 | <property name="position">0</property> | |
26 | </packing> | |
27 | </child> | |
28 | <child> | |
29 | <object class="GtkLabel" id="label2"> | |
30 | <property name="visible">True</property> | |
31 | <property name="can_focus">False</property> | |
32 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
33 | <property name="label" translatable="yes" context="the second label">This is a Label</property> | |
34 | </object> | |
35 | <packing> | |
36 | <property name="expand">True</property> | |
37 | <property name="fill">True</property> | |
38 | <property name="position">1</property> | |
39 | </packing> | |
40 | </child> | |
41 | <child> | |
42 | <object class="GtkButton" id="button1"> | |
43 | <property name="label" translatable="yes" comments="This button also includes translator comments">A button</property> | |
44 | <property name="visible">True</property> | |
45 | <property name="can_focus">True</property> | |
46 | <property name="receives_default">True</property> | |
47 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
48 | </object> | |
49 | <packing> | |
50 | <property name="expand">True</property> | |
51 | <property name="fill">True</property> | |
52 | <property name="position">2</property> | |
53 | </packing> | |
54 | </child> | |
55 | </object> | |
56 | </child> | |
57 | </object> | |
58 | </interface> |
12 | 12 | # Please view LICENSE for additional licensing information. |
13 | 13 | # ============================================================================= |
14 | 14 | |
15 | import os | |
15 | 16 | import unittest |
16 | try: | |
17 | from StringIO import StringIO ## for Python 2 | |
18 | except ImportError: | |
19 | from io import StringIO ## for Python 3from babel.messages.extract import DEFAULT_KEYWORDS | |
20 | 17 | from babelglade.extract import extract_glade |
18 | # from babel.messages.extract import DEFAULT_KEYWORDS | |
21 | 19 | |
22 | DEFAULT_KEYWORDS = "" | |
20 | DEFAULT_KEYWORDS = ("gettext", "pgettext") | |
21 | GLADE2_FILE = "test_extract.glade2.xml" | |
22 | GTKBUILDER_FILE = "test_extract.gtkbuilder.xml" | |
23 | ||
24 | ||
25 | def relative(test_file): | |
26 | return os.path.join(os.path.dirname(__file__), test_file) | |
27 | ||
23 | 28 | |
24 | 29 | class GladeExtractTests(unittest.TestCase): |
25 | 30 | |
26 | def setUp(self): | |
27 | self.glade_fileobj = StringIO("""\ | |
28 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
29 | <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> | |
30 | <glade-interface> | |
31 | <widget class="GtkWindow" id="window1"> | |
32 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
33 | <child> | |
34 | <widget class="GtkVBox" id="vbox1"> | |
35 | <property name="visible">True</property> | |
36 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
37 | <child> | |
38 | <widget class="GtkLabel" id="label1"> | |
39 | <property name="visible">True</property> | |
40 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
41 | <property name="label" translatable="yes" comments="A label with translator comments">This is a Label</property> | |
42 | </widget> | |
43 | </child> | |
44 | <child> | |
45 | <widget class="GtkButton" id="button1"> | |
46 | <property name="visible">True</property> | |
47 | <property name="can_focus">True</property> | |
48 | <property name="receives_default">True</property> | |
49 | <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> | |
50 | <property name="label" translatable="yes" comments="This button also includes translator comments">A button</property> | |
51 | </widget> | |
52 | <packing> | |
53 | <property name="position">1</property> | |
54 | </packing> | |
55 | </child> | |
56 | </widget> | |
57 | </child> | |
58 | </widget> | |
59 | </glade-interface> | |
60 | """) | |
31 | def test_glade2_yield_four_item_tuples_with_keywords(self): | |
32 | with open(relative(GLADE2_FILE), "r") as fp: | |
33 | extracted = extract_glade(fp, DEFAULT_KEYWORDS, None, {}) | |
34 | extracted = list(extracted) | |
35 | assert len(extracted) > 0, "extract_glade is not respecting presence of keywords" | |
36 | for entry in extracted: | |
37 | assert len(entry) == 4, "extract_glade did not return a tuple of length 4" | |
61 | 38 | |
62 | def test_yield_four_item_tuples_with_comments(self): | |
63 | extracted = extract_glade(self.glade_fileobj, DEFAULT_KEYWORDS, True, {}) | |
64 | for entry in list(extracted): | |
65 | assert len(entry) == 4, "extract_galde did not return a 4 tupple item" | |
39 | def test_glade2_yield_no_tuples_without_keywords(self): | |
40 | with open(relative(GLADE2_FILE), "r") as fp: | |
41 | extracted = extract_glade(fp, (), None, {}) | |
42 | extracted = list(extracted) | |
43 | assert len(extracted) == 0, "extract_glade is not respecting absence of keywords" | |
66 | 44 | |
67 | def test_yield_four_item_tuples_without_comments(self): | |
68 | extracted = extract_glade(self.glade_fileobj, DEFAULT_KEYWORDS, False, {}) | |
69 | for entry in list(extracted): | |
70 | assert len(entry) == 4, "extract_galde did not return a 4 tupple item" | |
45 | def test_gtkbuilder_yield_pgettext_tuples_for_elems_with_context(self): | |
46 | with open(relative(GTKBUILDER_FILE), "r") as fp: | |
47 | extracted = extract_glade(fp, ["pgettext"], None, {}) | |
48 | extracted = list(extracted) | |
49 | assert len(extracted) == 2, "extract_glade is not handling elems with context like pgettext" | |
50 | for entry in extracted: | |
51 | assert len(entry) == 4, "extract_glade did not return a tuple of length 4" | |
52 | lineno, funcname, message, comments = entry | |
53 | assert funcname == "pgettext", "extract_glade is not returning the right funcname (pgettext) for elems with context" | |
54 | assert isinstance(message, tuple) or isinstance(message, list), "extract_glade is not returning a tuple or a list when pretending it extracted from pgettext()" | |
55 | assert len(message) == 2, "extract_glade is not returning (ctx, msg) when pretending it extracted from pgettext()" | |
56 | ||
57 | def test_gtkbuilder_yield_gettext_tuples_for_elems_without_context(self): | |
58 | with open(relative(GTKBUILDER_FILE), "r") as fp: | |
59 | extracted = extract_glade(fp, ["gettext"], None, {}) | |
60 | extracted = list(extracted) | |
61 | assert len(extracted) == 1, "extract_glade is not handling elems without context like gettext" | |
62 | for entry in extracted: | |
63 | assert len(entry) == 4, "extract_glade did not return a tuple of length 4" | |
64 | lineno, funcname, message, comments = entry | |
65 | assert funcname == "gettext", "extract_glade is not returning the right funcname (gettext) for elems without any context" |
15 | 15 | |
16 | 16 | from setuptools import setup |
17 | 17 | |
18 | ||
19 | def _slurp(name): | |
20 | import os.path | |
21 | path = os.path.join(os.path.dirname(__file__), name) | |
22 | with open(path, encoding="utf-8") as fp: | |
23 | return fp.read() | |
24 | ||
25 | ||
18 | 26 | setup( |
19 | 27 | name = 'BabelGladeExtractor', |
20 | version = '0.6.3', | |
28 | version = '0.7.0', | |
21 | 29 | license = 'BSD', |
22 | 30 | author = 'Pedro Algarvio', |
23 | 31 | author_email = 'ufs@ufsoft.org', |
24 | 32 | maintainer = 'Tobias Mueller', |
25 | 33 | maintainer_email = 'tobiasmue@gnome.org', |
26 | description = 'Babel Glade XML files translatable strings extractor', | |
34 | description = 'Babel l10n support for Glade, GtkBuilder, and .desktop files', | |
35 | long_description = _slurp("README.md"), | |
36 | long_description_content_type = "text/markdown", | |
27 | 37 | url = 'https://github.com/GNOME-Keysign/babel-glade', |
28 | keywords = ['PyGTK', 'Glade', 'gettext', 'Babel', 'I18n', 'L10n'], | |
38 | keywords = ['PyGTK', 'PyGObject', 'Glade', 'GtkBuilder', 'gettext', 'Babel', 'I18n', 'L10n'], | |
29 | 39 | install_requires = ['Babel'], |
30 | 40 | test_suite = "babelglade.tests.suite", |
31 | 41 | entry_points = """ |