diff --git a/test/php/library/Icinga/Util/TranslatorTest.php b/test/php/library/Icinga/Util/TranslatorTest.php index 9e341d545..4d74cc8dc 100644 --- a/test/php/library/Icinga/Util/TranslatorTest.php +++ b/test/php/library/Icinga/Util/TranslatorTest.php @@ -213,4 +213,76 @@ class TranslatorTest extends BaseTestCase 'Translator::getPreferredLocaleCode does not return the default locale if no match could be found' ); } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsTheSingularForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('test service', 'test services', 1, 'icingatest'); + + $expected = 'test dienst'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated singular form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsThePluralForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('test service', 'test services', 2, 'icingatest'); + + $expected = 'test dienste'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated plural form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslateReturnsTheContextForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translate('context service', 'icingatest', 'test2'); + + $expected = 'context dienst test2'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translate() could not return the translated context form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsTheContextForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('context service', 'context services', 3, 'icingatest', 'test-context'); + + $expected = 'context plural dienste'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated context form' + ); + } } diff --git a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo index 487e49023..621eab2bf 100644 Binary files a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo and b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo differ diff --git a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po index 2bf77ccae..3215ac4f7 100644 --- a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po +++ b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po @@ -1,2 +1,42 @@ +msgid "" +msgstr "" +"Project-Id-Version: Icinga Web 2 Test (0.0.1)\n" +"Report-Msgid-Bugs-To: dev@icinga.org\n" +"POT-Creation-Date: 2014-09-16 13:29+0200\n" +"PO-Revision-Date: 2014-09-16 16:08+0100\n" +"Last-Translator: Alexander Fuhr \n" +"Language: de_DE\n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.5.4\n" + msgid "Lorem ipsum dolor sit amet" -msgstr "Lorem ipsum dolor sit amet!" \ No newline at end of file +msgstr "Lorem ipsum dolor sit amet!" + +msgid "test service" +msgid_plural "test services" +msgstr[0] "test dienst" +msgstr[1] "test dienste" + +msgctxt "test" +msgid "context service" +msgstr "context dienst test" + +msgctxt "test2" +msgid "context service" +msgstr "context dienst test2" + +msgctxt "test-contextu" +msgid "context service" +msgid_plural "context services" +msgstr[0] "context plural dienstu" +msgstr[1] "context plural diensteu" + +msgctxt "test-context" +msgid "context service" +msgid_plural "context services" +msgstr[0] "context plural dienst" +msgstr[1] "context plural dienste"