If you can't read please download the document
Upload
danielrhodes
View
10.214
Download
5
Embed Size (px)
DESCRIPTION
Internationalisation with PHP and the Intl extension. Featuring source code and three real world case studies.
Citation preview
2. What is the Intl extension?
3. Let's us...
5. Format text
6. See PHP docs athttp://www.php.net/manual/en/book.intl.php 7. Example locale differences
8. Korean language system of counting in tens of thousands. 10,000 is one man for example. 9. German alphabet with its umlauted vowels (, and ) and eszett () 10. How to get the extension
11. Bundled extension as of PHP 5.3.0 (compile freaks will want --enable-intl) 12. PHP 5.2.0 onwards can get the extension from PECL 13. ( http://www.php.net/manual/en/install.pecl.php ) 14. Check extension presence
15. First play and test 16. Functionality overview
17. Format currency amounts and other numbers (NumberFormatter class) 18. Locale getting, setting and information (Locale class) 19. Format natural language sentences (MessageFormatter class) 20. Format dates (IntlDateFormatter class) 21. And much more!(Transliterator class not yet implemented) 22. Case study sorting German
23. Dictionary ,phonebookandAustriansort orders 24. Seehttp://de.wikipedia.org/wiki/Alphabetische_Sortierung 25. Basically English A to Z order but with...
26. Where doeseszett go? ...to answer 27. Case study sorting German
28. Case study sorting German
29. What about the other two sort orders? 30. Well, sort() supports system locales... 31. ...so let's try that! 32. Case study sorting German 33. Case study sorting German
34. Setlocale() [and fgetcsv(), nl_langinfo(), localeconv() etc] needs system locale installed on OS 35. But system locale can be spelled differently,or be absent! , on different OS 36. And we still haven't got phonebook sort order! 37. A job for Intl... 38. Case study sorting German 39. Case study sorting German
40. ICU locales do not specify encoding (as ICU is for Unicode) 41. ICU locales specify variant locales differently 42. ICU locales support UCA keywords (eg. numbers=roman) 43. Challenge for you!
44. Collator::setAttribute() 45. Case study Japanese era
46. Basically the current emperor's reign is named Heisei and 2011 is Heisei 23 as it's the 23 rdyear of the current emperor's reign 47. Month and day same as Gregorian 48. Used for more official paperwork and formal situations (Gregorian year used day-to-day) 49. Let's see how Intl can present this format for a Japanese locale... 50. Case study Japanese era 51. Case study Japanese era
52. Because calendar=japanese supported by UCA 53. Give IntlDateFormatter::__construct()[email_address] =uca_calendar_typeandIntlDateFormatter::TRADITIONALto get non-Gregorian calendars 54. Challenge for you!
55. IntlDateFormatter::setPattern() 56. Case study Korean numbers
57. Korean equivalent of the newspaper style four million, two hundred thousand and forty-seven 58. So need Korean words / characters for numbers 59. BUT Korean counts in ten thousands 60. One, ten, hundred, thousand, man (ten thousand), eok (100 million ie. Ten thousand man), jo (one trillion ie. Ten thousand eok) 61. See http://en.wikipedia.org/wiki/Korean_numerals 62. Case study Korean numbers 63. Case study Korean numbers
64. We have to create, and then set, our own spellout rules 65. Luckily we can base our rules on the already present Japanese spellout rules! 66. Japanese also counts in ten thousands and uses non-Arabic numerals 67. Case study Korean numbers
68. Case study Korean numbers 69. Challenge for you!
70. Hanja 71. Financial / anti-forgery Hanja 72. (See http://en.wikipedia.org/wiki/Korean_numerals) 73. Summary
74. But we can usually set our own rules 75. Don't need to install locales on our OS 76. More flexible and fine-grained thansystemlocales (ie. setlocale() and money_format() etc) 77. NumberFormatter class also supports durations 78. Resource bundles for locale-specific messages, patterns etc supported with ResourceBundle class 79. Links
80. http://site.icu-project.org 81. http://www.php.net/manual/en/intro.intl.php 82. http://de.wikipedia.org/wiki/Alphabetische_Sortierung 83. http://en.wikipedia.org/wiki/Japanese_era 84. http://en.wikipedia.org/wiki/Korean_numerals