| 1 | <?php |
|---|
| 2 | include_once ('../boot.php'); |
|---|
| 3 | |
|---|
| 4 | ?><head> |
|---|
| 5 | |
|---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|---|
| 7 | |
|---|
| 8 | </head> |
|---|
| 9 | <body> |
|---|
| 10 | <h1>Zend_Locale::convertNumerals()</h1> |
|---|
| 11 | <p>Zf : <?php echo Zend_Version::VERSION;?></p> |
|---|
| 12 | |
|---|
| 13 | <a |
|---|
| 14 | href="http://framework.zend.com/manual/fr/zend.locale.parsing.html#zend.locale.numbersystems.example-2">31.40. |
|---|
| 15 | Converting numerals from Latin script to Eastern Arabic script</a> |
|---|
| 16 | <hr /> |
|---|
| 17 | <?php |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | $locale = new Zend_Locale(); |
|---|
| 21 | Zend_Debug::dump($locale->toString(), 'Locale'); |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | ini_set('iconv.internal_encoding', 'UTF-8'); // <- not clearly documented, |
|---|
| 25 | // but this script wont work without setting iconv.internal_encoding to utf-8, |
|---|
| 26 | // by default my php was iso-8856-1, and the function return NULL |
|---|
| 27 | // |
|---|
| 28 | // This issue was already fixed for the next minor release (1.10) |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | echo '<h2>Original script</h2>'; |
|---|
| 32 | |
|---|
| 33 | $latinScript = '1100 Tests23'; |
|---|
| 34 | $arabicScript = Zend_Locale_Format::convertNumerals($latinScript, |
|---|
| 35 | 'Latn', |
|---|
| 36 | 'Arab'); |
|---|
| 37 | |
|---|
| 38 | print "\nOriginal: " . $latinScript; |
|---|
| 39 | print "\nLocalized: " . $arabicScript; |
|---|
| 40 | |
|---|
| 41 | echo '<h2>All Numbering System script</h2>'; |
|---|
| 42 | |
|---|
| 43 | $latinNumber = rand(1234,6789) . ' Tests'; |
|---|
| 44 | |
|---|
| 45 | $list = Zend_Locale::getTranslationList('NumberingSystem', $locale); |
|---|
| 46 | echo count($list) . ' Numbering System founds |
|---|
| 47 | <dl> |
|---|
| 48 | '; |
|---|
| 49 | |
|---|
| 50 | foreach ($list as $targetScriptCode => $targetScriptName) { |
|---|
| 51 | print "\n <dt>" . $targetScriptCode . '<dd> ' ; |
|---|
| 52 | |
|---|
| 53 | $targetScript = Zend_Locale_Format::convertNumerals($latinNumber, 'latn', $targetScriptCode); |
|---|
| 54 | |
|---|
| 55 | Zend_Debug::dump($latinNumber, 'Original : '); |
|---|
| 56 | Zend_Debug::dump($targetScript, 'Localized : '); |
|---|
| 57 | } |
|---|
| 58 | echo '</dl>'; |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | dumpsource(__FILE__); |
|---|
| 62 | ?> |
|---|
| 63 | </body> |
|---|