root/trunk/Zend_Locale/Exemple.31.40.ConvertingNumeralsScriptLatin2EasternArabic.php

Revision 16, 1.9 KB (checked in by moosh, 2 years ago)
  • add patch for issue (solved in next ZF (1.10)
  • add orignal example from doc
  • print fz version
Line 
1<?php
2include_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.
15Converting numerals from Latin script to Eastern Arabic script</a>
16<hr />
17<?php
18
19
20$locale = new Zend_Locale();
21Zend_Debug::dump($locale->toString(), 'Locale');
22
23
24ini_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
31echo '<h2>Original script</h2>';
32
33$latinScript = '1100 Tests23';
34$arabicScript = Zend_Locale_Format::convertNumerals($latinScript,
35                                                    'Latn',
36                                                    'Arab');
37
38print "\nOriginal:  " . $latinScript;
39print "\nLocalized: " . $arabicScript;
40
41echo '<h2>All Numbering System script</h2>';
42
43$latinNumber = rand(1234,6789) . ' Tests';
44
45$list = Zend_Locale::getTranslationList('NumberingSystem', $locale);
46echo count($list) . ' Numbering System founds
47<dl>
48';
49
50foreach ($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}
58echo '</dl>';
59
60
61dumpsource(__FILE__);
62?>
63</body>
Note: See TracBrowser for help on using the browser.