From 0bf48df12a69c318847f36b8ac7ea786eb17649d Mon Sep 17 00:00:00 2001 From: Lea Tschiersch Date: Thu, 13 Feb 2020 15:00:20 +0100 Subject: [PATCH] Add test for multiple directories with custom domain --- .../de/LC_MESSAGES/myapp.mo | Bin 0 -> 594 bytes .../de/LC_MESSAGES/myapp.po | 35 ++++++++++++++++++ tests/test_integration.py | 33 +++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 tests/renamed_translations/de/LC_MESSAGES/myapp.mo create mode 100644 tests/renamed_translations/de/LC_MESSAGES/myapp.po diff --git a/tests/renamed_translations/de/LC_MESSAGES/myapp.mo b/tests/renamed_translations/de/LC_MESSAGES/myapp.mo new file mode 100644 index 0000000000000000000000000000000000000000..041aa3ca6e78e1d4fb22788fe5533dc457509e35 GIT binary patch literal 594 zcmZ8e!EV$r5Dm~%E=Zg?Op%bfLQb8Oiq_pNyWI_Rt1P?9MwO7@;AUr2Bgc+xr)oKK z;=l#*Mf?Zfg2N)(GV=4x^E}y}nO{$~egxjOJf3>=J95W9__#a&=<(R&v&SQkuO8nY z1i?4&yZp04Lx^87N?*`~QZFPqUWx9d|8#p4;yp%_jV|NXk-~6gC3o5|7@1lq z$hG3-B^v1Sjz{J%AM()CX+ZyFR_VY{A(NlhZ Ih-W, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2010-05-29 17:00+0200\n" +"PO-Revision-Date: 2010-05-30 12:56+0200\n" +"Last-Translator: Armin Ronacher \n" +"Language-Team: de \n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.5\n" + +#: tests.py:94 +#, python-format +msgid "Hello %(name)s!" +msgstr "Hallo %(name)s!" + +#: tests.py:95 tests.py:96 +#, python-format +msgid "%(num)s Apple" +msgid_plural "%(num)s Apples" +msgstr[0] "%(num)s Apfel" +msgstr[1] "%(num)s Äpfel" + +#: tests.py:119 +msgid "Yes" +msgstr "Ja" + diff --git a/tests/test_integration.py b/tests/test_integration.py index b488d55..2cd6f6c 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -49,6 +49,39 @@ def test_multiple_directories(): ) == 'Hallo Peter!' +def test_multiple_directories_different_domain(): + """ + Ensure we can load translations from multiple directories with a + custom domain. + """ + b = babel.Babel() + app = flask.Flask(__name__) + + app.config.update({ + 'BABEL_TRANSLATION_DIRECTORIES': ';'.join(( + 'translations_different_domain', + 'renamed_translations' + )), + 'BABEL_DEFAULT_LOCALE': 'de_DE', + 'BABEL_DOMAIN': 'myapp' + }) + + b.init_app(app) + + with app.test_request_context(): + translations = b.list_translations() + + assert(len(translations) == 2) + assert(str(translations[0]) == 'de') + assert(str(translations[1]) == 'de') + + assert gettext( + u'Hello %(name)s!', + name='Peter' + ) == 'Hallo Peter!' + assert gettext(u'Good bye') == 'Auf Wiedersehen' + + def test_different_domain(): """ Ensure we can load translations from multiple directories.