-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
363 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: pygettext.py 1.5\n" | ||
|
||
|
||
#: docstrings.py:7 | ||
#, docstring | ||
msgid "" | ||
msgstr "" | ||
|
||
#: docstrings.py:18 | ||
#, docstring | ||
msgid "" | ||
"multiline\n" | ||
" docstring\n" | ||
" " | ||
msgstr "" | ||
|
||
#: docstrings.py:25 | ||
#, docstring | ||
msgid "docstring1" | ||
msgstr "" | ||
|
||
#: docstrings.py:30 | ||
#, docstring | ||
msgid "Hello, {}!" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Test docstring extraction | ||
from gettext import gettext as _ | ||
|
||
|
||
# Empty docstring | ||
def test(x): | ||
"""""" | ||
|
||
|
||
# Leading empty line | ||
def test2(x): | ||
|
||
"""docstring""" # XXX This should be extracted but isn't. | ||
|
||
|
||
# XXX Multiline docstrings should be cleaned with `inspect.cleandoc`. | ||
def test3(x): | ||
"""multiline | ||
docstring | ||
""" | ||
|
||
|
||
# Multiple docstrings - only the first should be extracted | ||
def test4(x): | ||
"""docstring1""" | ||
"""docstring2""" | ||
|
||
|
||
def test5(x): | ||
"""Hello, {}!""".format("world!") # XXX This should not be extracted. | ||
|
||
|
||
# Nested docstrings | ||
def test6(x): | ||
def inner(y): | ||
"""nested docstring""" # XXX This should be extracted but isn't. | ||
|
||
|
||
class Outer: | ||
class Inner: | ||
"nested class docstring" # XXX This should be extracted but isn't. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: pygettext.py 1.5\n" | ||
|
||
|
||
#: fileloc.py:5 fileloc.py:6 | ||
msgid "foo" | ||
msgstr "" | ||
|
||
#: fileloc.py:9 | ||
msgid "bar" | ||
msgstr "" | ||
|
||
#: fileloc.py:14 fileloc.py:18 | ||
#, docstring | ||
msgid "docstring" | ||
msgstr "" | ||
|
||
#: fileloc.py:22 fileloc.py:26 | ||
#, docstring | ||
msgid "baz" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Test file locations | ||
from gettext import gettext as _ | ||
|
||
# Duplicate strings | ||
_('foo') | ||
_('foo') | ||
|
||
# Duplicate strings on the same line should only add one location to the output | ||
_('bar'), _('bar') | ||
|
||
|
||
# Duplicate docstrings | ||
class A: | ||
"""docstring""" | ||
|
||
|
||
def f(): | ||
"""docstring""" | ||
|
||
|
||
# Duplicate message and docstring | ||
_('baz') | ||
|
||
|
||
def g(): | ||
"""baz""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: pygettext.py 1.5\n" | ||
|
||
|
||
#: messages.py:5 | ||
msgid "" | ||
msgstr "" | ||
|
||
#: messages.py:8 messages.py:9 | ||
msgid "parentheses" | ||
msgstr "" | ||
|
||
#: messages.py:12 | ||
msgid "Hello, world!" | ||
msgstr "" | ||
|
||
#: messages.py:15 | ||
msgid "" | ||
"Hello,\n" | ||
" multiline!\n" | ||
msgstr "" | ||
|
||
#: messages.py:29 | ||
msgid "Hello, {}!" | ||
msgstr "" | ||
|
||
#: messages.py:33 | ||
msgid "1" | ||
msgstr "" | ||
|
||
#: messages.py:33 | ||
msgid "2" | ||
msgstr "" | ||
|
||
#: messages.py:34 messages.py:35 | ||
msgid "A" | ||
msgstr "" | ||
|
||
#: messages.py:34 messages.py:35 | ||
msgid "B" | ||
msgstr "" | ||
|
||
#: messages.py:36 | ||
msgid "set" | ||
msgstr "" | ||
|
||
#: messages.py:42 | ||
msgid "nested string" | ||
msgstr "" | ||
|
||
#: messages.py:47 | ||
msgid "baz" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Test message extraction | ||
from gettext import gettext as _ | ||
|
||
# Empty string | ||
_("") | ||
|
||
# Extra parentheses | ||
(_("parentheses")) | ||
((_("parentheses"))) | ||
|
||
# Multiline strings | ||
_("Hello, " | ||
"world!") | ||
|
||
_("""Hello, | ||
multiline! | ||
""") | ||
|
||
# Invalid arguments | ||
_() | ||
_(None) | ||
_(1) | ||
_(False) | ||
_(x="kwargs are not allowed") | ||
_("foo", "bar") | ||
_("something", x="something else") | ||
|
||
# .format() | ||
_("Hello, {}!").format("world") # valid | ||
_("Hello, {}!".format("world")) # invalid | ||
|
||
# Nested structures | ||
_("1"), _("2") | ||
arr = [_("A"), _("B")] | ||
obj = {'a': _("A"), 'b': _("B")} | ||
{{{_('set')}}} | ||
|
||
|
||
# Nested functions and classes | ||
def test(): | ||
_("nested string") # XXX This should be extracted but isn't. | ||
[_("nested string")] | ||
|
||
|
||
class Foo: | ||
def bar(self): | ||
return _("baz") | ||
|
||
|
||
def bar(x=_('default value')): # XXX This should be extracted but isn't. | ||
pass | ||
|
||
|
||
def baz(x=[_('default value')]): # XXX This should be extracted but isn't. | ||
pass | ||
|
||
|
||
# Shadowing _() | ||
def _(x): | ||
pass | ||
|
||
|
||
def _(x="don't extract me"): | ||
pass |
Oops, something went wrong.