| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
function __($text, $args = array(), $catalogue = 'messages') |
|---|
| 21 |
{ |
|---|
| 22 |
if (sfConfig::get('sf_i18n')) |
|---|
| 23 |
{ |
|---|
| 24 |
return sfContext::getInstance()->getI18N()->__($text, $args, $catalogue); |
|---|
| 25 |
} |
|---|
| 26 |
else |
|---|
| 27 |
{ |
|---|
| 28 |
if (empty($args)) |
|---|
| 29 |
{ |
|---|
| 30 |
$args = array(); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
foreach ($args as $key => $value) |
|---|
| 35 |
{ |
|---|
| 36 |
if (is_object($value) && method_exists($value, '__toString')) |
|---|
| 37 |
{ |
|---|
| 38 |
$args[$key] = $value->__toString(); |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
return strtr($text, $args); |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
function format_number_choice($text, $args = array(), $number, $catalogue = 'messages') |
|---|
| 64 |
{ |
|---|
| 65 |
$translated = __($text, $args, $catalogue); |
|---|
| 66 |
|
|---|
| 67 |
$choice = new sfChoiceFormat(); |
|---|
| 68 |
|
|---|
| 69 |
$retval = $choice->format($translated, $number); |
|---|
| 70 |
|
|---|
| 71 |
if ($retval === false) |
|---|
| 72 |
{ |
|---|
| 73 |
throw new sfException(sprintf('Unable to parse your choice "%s".', $translated)); |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
return $retval; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
function format_country($country_iso, $culture = null) |
|---|
| 80 |
{ |
|---|
| 81 |
$c = sfCultureInfo::getInstance($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture); |
|---|
| 82 |
$countries = $c->getCountries(); |
|---|
| 83 |
|
|---|
| 84 |
return isset($countries[$country_iso]) ? $countries[$country_iso] : ''; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
function format_language($language_iso, $culture = null) |
|---|
| 88 |
{ |
|---|
| 89 |
$c = sfCultureInfo::getInstance($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture); |
|---|
| 90 |
$languages = $c->getLanguages(); |
|---|
| 91 |
|
|---|
| 92 |
return isset($languages[$language_iso]) ? $languages[$language_iso] : ''; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|