diff --git a/CHANGELOG.md b/CHANGELOG.md index d881fac6..e27cea34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # PrivateBin version history + * **next (not yet released)** + * ADDED: Translations for Spanish * **1.1 (2016-12-26)** * ADDED: Translations for Italian and Russian * ADDED: Loading message displayed until decryption succeeded for slower (in terms of CPU or network) systems diff --git a/CREDITS.md b/CREDITS.md index 3115aa08..60391fa6 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -32,3 +32,4 @@ Sébastien Sauvage - original idea and main developer * Jiawei Zhou - Chinese * Stefano Marty - Italian * R4SAS - Russian +* Alfredo Fabián Altamirano Tena - Spanish diff --git a/index.php b/index.php index 2b3ceb37..6b04012b 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ * @link https://github.com/PrivateBin/PrivateBin * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License - * @version 1.0 + * @version 1.1 */ // change this, if your php files and data is outside of your webservers document root diff --git a/js/privatebin.js b/js/privatebin.js index 97803636..6efaf464 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -414,10 +414,12 @@ $(function() { case 'zh': return (n > 1 ? 1 : 0); case 'pl': - return (n === 1 ? 0 : (n%10 >= 2 && n %10 <=4 && (n%100 < 10 || n%100 >= 20) ? 1 : 2)); + return (n === 1 ? 0 : (n % 10 >= 2 && n %10 <=4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2)); case 'ru': return (n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2)); - // en, de + case 'sl': + return (n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0))); + // de, en, es, it default: return (n !== 1 ? 1 : 0); } diff --git a/lib/I18n.php b/lib/I18n.php index 1ced8622..c7c66835 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -301,7 +301,9 @@ class I18n return $n == 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2); case 'ru': return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2); - // en, de + case 'sl': + return $n % 100 == 1 ? 1 : ($n % 100 == 2 ? 2 : ($n % 100 == 3 || $n % 100 == 4 ? 3 : 0)); + // de, en, es, it default: return $n != 1 ? 1 : 0; } diff --git a/tpl/bootstrap-compact.php b/tpl/bootstrap-compact.php index db8d0267..63390dd3 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 e7c6f000..021439ba 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 e4b0b51f..e8704ea4 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 bb65a751..fb595c13 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 c3968e39..011c0502 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 77cfac57..564d1600 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 c4bc51a8..06f13603 100644 --- a/tst/I18nTest.php +++ b/tst/I18nTest.php @@ -84,6 +84,21 @@ class I18nTest extends PHPUnit_Framework_TestCase $this->assertEquals('21 минуту', I18n::_('%d minutes', 21), '21 minutes in russian'); } + public function testBrowserLanguageSlDetection() + { + $_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'); + } + public function testBrowserLanguageAnyDetection() { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = '*';