locale_get_keywords2.phpt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. --TEST--
  2. locale_get_keywords() icu >= 4.8
  3. --SKIPIF--
  4. <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
  5. <?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
  6. --FILE--
  7. <?php
  8. /*
  9. * Try getting the keywords for different locales
  10. * with Procedural and Object methods.
  11. */
  12. function ut_main()
  13. {
  14. $res_str = '';
  15. $locales = array(
  16. "de_DE@currency=EUR;collation=PHONEBOOK",
  17. 'uk-ua_CALIFORNIA@currency=GRN'
  18. );
  19. $locales = array(
  20. 'de_DE@currency=EUR;collation=PHONEBOOK',
  21. 'root',
  22. 'uk@currency=EURO',
  23. 'Hindi',
  24. //Simple language subtag
  25. 'de',
  26. 'fr',
  27. 'ja',
  28. 'i-enochian', //(example of a grandfathered tag)
  29. //Language subtag plus Script subtag:
  30. 'zh-Hant',
  31. 'zh-Hans',
  32. 'sr-Cyrl',
  33. 'sr-Latn',
  34. //Language-Script-Region
  35. 'zh-Hans-CN',
  36. 'sr-Latn-CS',
  37. //Language-Variant
  38. 'sl-rozaj',
  39. 'sl-nedis',
  40. //Language-Region-Variant
  41. 'de-CH-1901',
  42. 'sl-IT-nedis',
  43. //Language-Script-Region-Variant
  44. 'sl-Latn-IT-nedis',
  45. //Language-Region:
  46. 'de-DE',
  47. 'en-US',
  48. 'es-419',
  49. //Private use subtags:
  50. 'de-CH-x-phonebk',
  51. 'az-Arab-x-AZE-derbend',
  52. //Extended language subtags
  53. 'zh-min',
  54. 'zh-min-nan-Hant-CN',
  55. //Private use registry values
  56. 'x-whatever',
  57. 'qaa-Qaaa-QM-x-southern',
  58. 'sr-Latn-QM',
  59. 'sr-Qaaa-CS',
  60. /*Tags that use extensions (examples ONLY: extensions MUST be defined
  61. by revision or update to this document or by RFC): */
  62. 'en-US-u-islamCal',
  63. 'zh-CN-a-myExt-x-private',
  64. 'en-a-myExt-b-another',
  65. //Some Invalid Tags:
  66. 'de-419-DE',
  67. 'a-DE',
  68. 'ar-a-aaa-b-bbb-a-ccc'
  69. );
  70. $res_str = '';
  71. foreach( $locales as $locale )
  72. {
  73. $keywords_arr = ut_loc_get_keywords( $locale);
  74. $res_str .= "$locale: ";
  75. if( $keywords_arr){
  76. foreach( $keywords_arr as $key => $value){
  77. $res_str .= "Key is $key and Value is $value \n";
  78. }
  79. }
  80. else{
  81. $res_str .= "No keywords found.";
  82. }
  83. $res_str .= "\n";
  84. }
  85. $res_str .= "\n";
  86. return $res_str;
  87. }
  88. include_once( 'ut_common.inc' );
  89. ut_run();
  90. ?>
  91. --EXPECT--
  92. de_DE@currency=EUR;collation=PHONEBOOK: Key is collation and Value is PHONEBOOK
  93. Key is currency and Value is EUR
  94. root: No keywords found.
  95. uk@currency=EURO: Key is currency and Value is EURO
  96. Hindi: No keywords found.
  97. de: No keywords found.
  98. fr: No keywords found.
  99. ja: No keywords found.
  100. i-enochian: Key is x and Value is i-enochian
  101. zh-Hant: No keywords found.
  102. zh-Hans: No keywords found.
  103. sr-Cyrl: No keywords found.
  104. sr-Latn: No keywords found.
  105. zh-Hans-CN: No keywords found.
  106. sr-Latn-CS: No keywords found.
  107. sl-rozaj: No keywords found.
  108. sl-nedis: No keywords found.
  109. de-CH-1901: No keywords found.
  110. sl-IT-nedis: No keywords found.
  111. sl-Latn-IT-nedis: No keywords found.
  112. de-DE: No keywords found.
  113. en-US: No keywords found.
  114. es-419: No keywords found.
  115. de-CH-x-phonebk: Key is x and Value is phonebk
  116. az-Arab-x-AZE-derbend: Key is x and Value is aze-derbend
  117. zh-min: No keywords found.
  118. zh-min-nan-Hant-CN: No keywords found.
  119. x-whatever: Key is x and Value is whatever
  120. qaa-Qaaa-QM-x-southern: Key is x and Value is southern
  121. sr-Latn-QM: No keywords found.
  122. sr-Qaaa-CS: No keywords found.
  123. en-US-u-islamCal: Key is attribute and Value is islamcal
  124. zh-CN-a-myExt-x-private: Key is a and Value is myext
  125. Key is x and Value is private
  126. en-a-myExt-b-another: Key is a and Value is myext
  127. Key is b and Value is another
  128. de-419-DE: No keywords found.
  129. a-DE: No keywords found.
  130. ar-a-aaa-b-bbb-a-ccc: Key is a and Value is aaa
  131. Key is b and Value is bbb