Choosing correct Occitan plural formula, added unit tests for Occitan and Chinese, corrected casing of languages in unit test
This commit is contained in:
parent
20fea819cb
commit
f79c00378b
9 changed files with 57 additions and 35 deletions
|
@ -411,6 +411,7 @@ $(function() {
|
||||||
switch (this.language)
|
switch (this.language)
|
||||||
{
|
{
|
||||||
case 'fr':
|
case 'fr':
|
||||||
|
case 'oc':
|
||||||
case 'zh':
|
case 'zh':
|
||||||
return (n > 1 ? 1 : 0);
|
return (n > 1 ? 1 : 0);
|
||||||
case 'pl':
|
case 'pl':
|
||||||
|
|
|
@ -295,6 +295,7 @@ class I18n
|
||||||
{
|
{
|
||||||
switch (self::$_language) {
|
switch (self::$_language) {
|
||||||
case 'fr':
|
case 'fr':
|
||||||
|
case 'oc':
|
||||||
case 'zh':
|
case 'zh':
|
||||||
return $n > 1 ? 1 : 0;
|
return $n > 1 ? 1 : 0;
|
||||||
case 'pl':
|
case 'pl':
|
||||||
|
|
|
@ -52,7 +52,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -52,7 +52,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -53,7 +53,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -52,7 +52,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -53,7 +53,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-IW6J8BFdteIny5Ap+B6F6XMxi5G8x7TMLD/ii+8Q+/KKhutdNDBWozNS2DXbzXdm5KZBtP7U2qSY46EdMl0DMw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-7C0R3df9nbM/VHCi2PpuEy14FC3os6JQfEkI6u4fjKn5xMlNJAozHJCwP/4bQiXxeqMy64Xi6VmZgaG6dwjAgg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -33,9 +33,9 @@ class I18nTest extends PHPUnit_Framework_TestCase
|
||||||
$_COOKIE['lang'] = 'de';
|
$_COOKIE['lang'] = 'de';
|
||||||
I18n::loadTranslations();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
|
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
|
||||||
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in german');
|
$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('1 Stunde', I18n::_('%d hours', 1), '1 hour in German');
|
||||||
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in french');
|
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in German');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageDeDetection()
|
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';
|
$_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();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
|
$this->assertEquals($this->_translations['en'], I18n::_('en'), 'browser language de');
|
||||||
$this->assertEquals('0 Stunden', I18n::_('%d hours', 0), '0 hours in german');
|
$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('1 Stunde', I18n::_('%d hours', 1), '1 hour in German');
|
||||||
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in french');
|
$this->assertEquals('2 Stunden', I18n::_('%d hours', 2), '2 hours in German');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageFrDetection()
|
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';
|
$_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();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals('fr', I18n::_('en'), 'browser language fr');
|
$this->assertEquals('fr', I18n::_('en'), 'browser language fr');
|
||||||
$this->assertEquals('0 heure', I18n::_('%d hours', 0), '0 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('1 heure', I18n::_('%d hours', 1), '1 hour in French');
|
||||||
$this->assertEquals('2 heures', I18n::_('%d hours', 2), '2 hours 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()
|
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';
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'pl;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||||
I18n::loadTranslations();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals('pl', I18n::_('en'), 'browser language pl');
|
$this->assertEquals('pl', I18n::_('en'), 'browser language pl');
|
||||||
$this->assertEquals('1 godzina', I18n::_('%d hours', 1), '1 hour 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('2 godzina', I18n::_('%d hours', 2), '2 hours in Polish');
|
||||||
$this->assertEquals('12 godzinę', I18n::_('%d hours', 12), '12 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('22 godzina', I18n::_('%d hours', 22), '22 hours in Polish');
|
||||||
$this->assertEquals('1 minut', I18n::_('%d minutes', 1), '1 minute 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('3 minut', I18n::_('%d minutes', 3), '3 minutes in Polish');
|
||||||
$this->assertEquals('13 minut', I18n::_('%d minutes', 13), '13 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('23 minut', I18n::_('%d minutes', 23), '23 minutes in Polish');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageRuDetection()
|
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';
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ru;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||||
I18n::loadTranslations();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals('ru', I18n::_('en'), 'browser language ru');
|
$this->assertEquals('ru', I18n::_('en'), 'browser language ru');
|
||||||
$this->assertEquals('1 минуту', I18n::_('%d minutes', 1), '1 minute 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('3 минуты', I18n::_('%d minutes', 3), '3 minutes in Russian');
|
||||||
$this->assertEquals('10 минут', I18n::_('%d minutes', 10), '10 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('21 минуту', I18n::_('%d minutes', 21), '21 minutes in Russian');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageSlDetection()
|
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';
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'sl;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||||
I18n::loadTranslations();
|
I18n::loadTranslations();
|
||||||
$this->assertEquals('sl', I18n::_('en'), 'browser language sl');
|
$this->assertEquals('sl', I18n::_('en'), 'browser language sl');
|
||||||
$this->assertEquals('0 ura', I18n::_('%d hours', 0), '0 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('1 uri', I18n::_('%d hours', 1), '1 hour in Slowene');
|
||||||
$this->assertEquals('2 ure', I18n::_('%d hours', 2), '2 hours 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('3 ur', I18n::_('%d hours', 3), '3 hours in Slowene');
|
||||||
$this->assertEquals('11 ura', I18n::_('%d hours', 11), '11 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('101 uri', I18n::_('%d hours', 101), '101 hours in Slowene');
|
||||||
$this->assertEquals('102 ure', I18n::_('%d hours', 102), '102 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('104 ur', I18n::_('%d hours', 104), '104 hours in Slowene');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageAnyDetection()
|
public function testBrowserLanguageAnyDetection()
|
||||||
|
|
Loading…
Reference in a new issue