diff --git a/js/privatebin.js b/js/privatebin.js index 1a53d83..7030afb 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -411,6 +411,7 @@ $(function() { switch (this.language) { case 'fr': + case 'oc': case 'zh': return (n > 1 ? 1 : 0); case 'pl': diff --git a/lib/I18n.php b/lib/I18n.php index c7c6683..6419fee 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -295,6 +295,7 @@ class I18n { switch (self::$_language) { case 'fr': + case 'oc': case 'zh': return $n > 1 ? 1 : 0; case 'pl': diff --git a/tpl/bootstrap-compact.php b/tpl/bootstrap-compact.php index 2dbf5c6..795ba03 100644 --- a/tpl/bootstrap-compact.php +++ b/tpl/bootstrap-compact.php @@ -52,7 +52,7 @@ if ($MARKDOWN): - + diff --git a/tpl/bootstrap-dark-page.php b/tpl/bootstrap-dark-page.php index 5984556..fd0515b 100644 --- a/tpl/bootstrap-dark-page.php +++ b/tpl/bootstrap-dark-page.php @@ -52,7 +52,7 @@ if ($MARKDOWN): - + diff --git a/tpl/bootstrap-dark.php b/tpl/bootstrap-dark.php index 13a94b6..b30b68d 100644 --- a/tpl/bootstrap-dark.php +++ b/tpl/bootstrap-dark.php @@ -53,7 +53,7 @@ if ($MARKDOWN): - + diff --git a/tpl/bootstrap-page.php b/tpl/bootstrap-page.php index f146ec3..f9bd932 100644 --- a/tpl/bootstrap-page.php +++ b/tpl/bootstrap-page.php @@ -52,7 +52,7 @@ if ($MARKDOWN): - + diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 6cbb24d..38a948e 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -53,7 +53,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index 4d93a79..02570b5 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -47,7 +47,7 @@ if ($MARKDOWN): - + diff --git a/tst/I18nTest.php b/tst/I18nTest.php index 06f1360..7c75b69 100644 --- a/tst/I18nTest.php +++ b/tst/I18nTest.php @@ -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()