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 0000000..041aa3c Binary files /dev/null and b/tests/renamed_translations/de/LC_MESSAGES/myapp.mo differ diff --git a/tests/renamed_translations/de/LC_MESSAGES/myapp.po b/tests/renamed_translations/de/LC_MESSAGES/myapp.po new file mode 100644 index 0000000..6d6ea80 --- /dev/null +++ b/tests/renamed_translations/de/LC_MESSAGES/myapp.po @@ -0,0 +1,35 @@ +# German translations for PROJECT. +# Copyright (C) 2010 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 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.