Choosing correct Occitan plural formula, added unit tests for Occitan and Chinese, corrected casing of languages in unit test

This commit is contained in:
El RIDO
2017-01-08 07:56:56 +01:00
parent 20fea819cb
commit f79c00378b
9 changed files with 57 additions and 35 deletions

View File

@@ -33,9 +33,9 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_COOKIE['lang'] = 'de';
I18n::loadTranslations();
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in german');
$this->assertEquals('1 Stunde', I18n::_('%d hours', 1), '1 hour in german');
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in french');
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in German');
$this->assertEquals('1 Stunde', I18n::_('%d hours', 1), '1 hour in German');
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in German');
}
public function testBrowserLanguageDeDetection()
@@ -43,9 +43,9 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-CH,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in german');
$this->assertEquals('1 Stunde', I18n::_('%d hours', 1), '1 hour in german');
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in french');
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in German');
$this->assertEquals('1 Stunde', I18n::_('%d hours', 1), '1 hour in German');
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in German');
}
public function testBrowserLanguageFrDetection()
@@ -53,9 +53,29 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr-CH,fr;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('fr', I18n::_('en'), 'browser language fr');
$this->assertEquals('0 heure', I18n::_('%d hours', 0), '0 hours in french');
$this->assertEquals('1 heure', I18n::_('%d hours', 1), '1 hour in french');
$this->assertEquals('2 heures', I18n::_('%d hours', 2), '2 hours in french');
$this->assertEquals('0 heure', I18n::_('%d hours', 0), '0 hours in French');
$this->assertEquals('1 heure', I18n::_('%d hours', 1), '1 hour in French');
$this->assertEquals('2 heures', I18n::_('%d hours', 2), '2 hours in French');
}
public function testBrowserLanguageOcDetection()
{
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'oc;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('oc', I18n::_('en'), 'browser language oc');
$this->assertEquals('0 ora', I18n::_('%d hours', 0), '0 hours in Occitan');
$this->assertEquals('1 ora', I18n::_('%d hours', 1), '1 hour in Occitan');
$this->assertEquals('2 oras', I18n::_('%d hours', 2), '2 hours in Occitan');
}
public function testBrowserLanguageZhDetection()
{
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'zh;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('zh', I18n::_('en'), 'browser language zh');
$this->assertEquals('0 小时', I18n::_('%d hours', 0), '0 hours in Chinese');
$this->assertEquals('1 小时', I18n::_('%d hours', 1), '1 hour in Chinese');
$this->assertEquals('2 小时', I18n::_('%d hours', 2), '2 hours in Chinese');
}
public function testBrowserLanguagePlDetection()
@@ -63,14 +83,14 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'pl;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('pl', I18n::_('en'), 'browser language pl');
$this->assertEquals('1 godzina', I18n::_('%d hours', 1), '1 hour in polish');
$this->assertEquals('2 godzina', I18n::_('%d hours', 2), '2 hours in polish');
$this->assertEquals('12 godzinę', I18n::_('%d hours', 12), '12 hours in polish');
$this->assertEquals('22 godzina', I18n::_('%d hours', 22), '22 hours in polish');
$this->assertEquals('1 minut', I18n::_('%d minutes', 1), '1 minute in polish');
$this->assertEquals('3 minut', I18n::_('%d minutes', 3), '3 minutes in polish');
$this->assertEquals('13 minut', I18n::_('%d minutes', 13), '13 minutes in polish');
$this->assertEquals('23 minut', I18n::_('%d minutes', 23), '23 minutes in polish');
$this->assertEquals('1 godzina', I18n::_('%d hours', 1), '1 hour in Polish');
$this->assertEquals('2 godzina', I18n::_('%d hours', 2), '2 hours in Polish');
$this->assertEquals('12 godzinę', I18n::_('%d hours', 12), '12 hours in Polish');
$this->assertEquals('22 godzina', I18n::_('%d hours', 22), '22 hours in Polish');
$this->assertEquals('1 minut', I18n::_('%d minutes', 1), '1 minute in Polish');
$this->assertEquals('3 minut', I18n::_('%d minutes', 3), '3 minutes in Polish');
$this->assertEquals('13 minut', I18n::_('%d minutes', 13), '13 minutes in Polish');
$this->assertEquals('23 minut', I18n::_('%d minutes', 23), '23 minutes in Polish');
}
public function testBrowserLanguageRuDetection()
@@ -78,10 +98,10 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ru;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('ru', I18n::_('en'), 'browser language ru');
$this->assertEquals('1 минуту', I18n::_('%d minutes', 1), '1 minute in russian');
$this->assertEquals('3 минуты', I18n::_('%d minutes', 3), '3 minutes in russian');
$this->assertEquals('10 минут', I18n::_('%d minutes', 10), '10 minutes in russian');
$this->assertEquals('21 минуту', I18n::_('%d minutes', 21), '21 minutes in russian');
$this->assertEquals('1 минуту', I18n::_('%d minutes', 1), '1 minute in Russian');
$this->assertEquals('3 минуты', I18n::_('%d minutes', 3), '3 minutes in Russian');
$this->assertEquals('10 минут', I18n::_('%d minutes', 10), '10 minutes in Russian');
$this->assertEquals('21 минуту', I18n::_('%d minutes', 21), '21 minutes in Russian');
}
public function testBrowserLanguageSlDetection()
@@ -89,14 +109,14 @@ class I18nTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'sl;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
I18n::loadTranslations();
$this->assertEquals('sl', I18n::_('en'), 'browser language sl');
$this->assertEquals('0 ura', I18n::_('%d hours', 0), '0 hours in slowene');
$this->assertEquals('1 uri', I18n::_('%d hours', 1), '1 hour in slowene');
$this->assertEquals('2 ure', I18n::_('%d hours', 2), '2 hours in slowene');
$this->assertEquals('3 ur', I18n::_('%d hours', 3), '3 hours in slowene');
$this->assertEquals('11 ura', I18n::_('%d hours', 11), '11 hours in slowene');
$this->assertEquals('101 uri', I18n::_('%d hours', 101), '101 hours in slowene');
$this->assertEquals('102 ure', I18n::_('%d hours', 102), '102 hours in slowene');
$this->assertEquals('104 ur', I18n::_('%d hours', 104), '104 hours in slowene');
$this->assertEquals('0 ura', I18n::_('%d hours', 0), '0 hours in Slowene');
$this->assertEquals('1 uri', I18n::_('%d hours', 1), '1 hour in Slowene');
$this->assertEquals('2 ure', I18n::_('%d hours', 2), '2 hours in Slowene');
$this->assertEquals('3 ur', I18n::_('%d hours', 3), '3 hours in Slowene');
$this->assertEquals('11 ura', I18n::_('%d hours', 11), '11 hours in Slowene');
$this->assertEquals('101 uri', I18n::_('%d hours', 101), '101 hours in Slowene');
$this->assertEquals('102 ure', I18n::_('%d hours', 102), '102 hours in Slowene');
$this->assertEquals('104 ur', I18n::_('%d hours', 104), '104 hours in Slowene');
}
public function testBrowserLanguageAnyDetection()