178 lines
5.3 KiB
PHP
178 lines
5.3 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Zend Framework
|
||
|
*
|
||
|
* LICENSE
|
||
|
*
|
||
|
* This source file is subject to the new BSD license that is bundled
|
||
|
* with this package in the file LICENSE.txt.
|
||
|
* It is also available through the world-wide-web at this URL:
|
||
|
* http://framework.zend.com/license/new-bsd
|
||
|
* If you did not receive a copy of the license and are unable to
|
||
|
* obtain it through the world-wide-web, please send an email
|
||
|
* to license@zend.com so we can send you a copy immediately.
|
||
|
*
|
||
|
* @category Zend
|
||
|
* @package Zend_Locale
|
||
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||
|
* @version $Id: Plural.php 17439 2009-08-07 19:25:20Z thomas $
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Utility class for returning the plural rules according to the given locale
|
||
|
*
|
||
|
* @category Zend
|
||
|
* @package Zend_Locale
|
||
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||
|
*/
|
||
|
class Zend_Translate_Plural
|
||
|
{
|
||
|
/**
|
||
|
* Returns the plural definition to use
|
||
|
*/
|
||
|
public static function getPlural($number, $locale)
|
||
|
{
|
||
|
if ($locale == "pt_BR") {
|
||
|
// temporary set a locale for brasilian
|
||
|
$locale = "xbr";
|
||
|
}
|
||
|
|
||
|
if (strlen($locale) > 3) {
|
||
|
$locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
|
||
|
}
|
||
|
|
||
|
switch($locale) {
|
||
|
case 'bo':
|
||
|
case 'dz':
|
||
|
case 'id':
|
||
|
case 'ja':
|
||
|
case 'jv':
|
||
|
case 'ka':
|
||
|
case 'km':
|
||
|
case 'kn':
|
||
|
case 'ko':
|
||
|
case 'ms':
|
||
|
case 'th':
|
||
|
case 'tr':
|
||
|
case 'vi':
|
||
|
return 0;
|
||
|
break;
|
||
|
|
||
|
case 'af':
|
||
|
case 'az':
|
||
|
case 'bn':
|
||
|
case 'bg':
|
||
|
case 'ca':
|
||
|
case 'da':
|
||
|
case 'de':
|
||
|
case 'el':
|
||
|
case 'en':
|
||
|
case 'eo':
|
||
|
case 'es':
|
||
|
case 'et':
|
||
|
case 'eu':
|
||
|
case 'fa':
|
||
|
case 'fi':
|
||
|
case 'fo':
|
||
|
case 'fur':
|
||
|
case 'fy':
|
||
|
case 'gl':
|
||
|
case 'gu':
|
||
|
case 'ha':
|
||
|
case 'he':
|
||
|
case 'hu':
|
||
|
case 'is':
|
||
|
case 'it':
|
||
|
case 'ku':
|
||
|
case 'lb':
|
||
|
case 'ml':
|
||
|
case 'mn':
|
||
|
case 'mr':
|
||
|
case 'nah':
|
||
|
case 'nb':
|
||
|
case 'ne':
|
||
|
case 'nl':
|
||
|
case 'nn':
|
||
|
case 'no':
|
||
|
case 'om':
|
||
|
case 'or':
|
||
|
case 'pa':
|
||
|
case 'pap':
|
||
|
case 'ps':
|
||
|
case 'pt':
|
||
|
case 'so':
|
||
|
case 'sq':
|
||
|
case 'sv':
|
||
|
case 'sw':
|
||
|
case 'ta':
|
||
|
case 'te':
|
||
|
case 'tk':
|
||
|
case 'ur':
|
||
|
case 'zh':
|
||
|
case 'zu':
|
||
|
return ($number == 1) ? 0 : 1;
|
||
|
|
||
|
case 'am':
|
||
|
case 'bh':
|
||
|
case 'fil':
|
||
|
case 'fr':
|
||
|
case 'gun':
|
||
|
case 'hi':
|
||
|
case 'ln':
|
||
|
case 'mg':
|
||
|
case 'nso':
|
||
|
case 'xbr':
|
||
|
case 'ti':
|
||
|
case 'wa':
|
||
|
return (($number == 0) || ($number == 1)) ? 0 : 1;
|
||
|
|
||
|
case 'be':
|
||
|
case 'bs':
|
||
|
case 'hr':
|
||
|
case 'ru':
|
||
|
case 'sr':
|
||
|
case 'uk':
|
||
|
return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
|
||
|
|
||
|
case 'cs':
|
||
|
case 'sk':
|
||
|
return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
|
||
|
|
||
|
case 'ga':
|
||
|
return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
|
||
|
|
||
|
case 'lt':
|
||
|
return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
|
||
|
|
||
|
case 'sl':
|
||
|
return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
|
||
|
|
||
|
case 'mk':
|
||
|
return ($number % 10 == 1) ? 0 : 1;
|
||
|
|
||
|
case 'mt':
|
||
|
return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
|
||
|
|
||
|
case 'lv':
|
||
|
return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
|
||
|
|
||
|
case 'pl':
|
||
|
return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 > 29))) ? 1 : 2);
|
||
|
|
||
|
case 'cy':
|
||
|
return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
|
||
|
|
||
|
case 'ro':
|
||
|
return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
|
||
|
|
||
|
case 'ar':
|
||
|
return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number >= 3) && ($number <= 10)) ? 3 : ((($number >= 11) && ($number <= 99)) ? 4 : 5))));
|
||
|
|
||
|
default:
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
}
|