Localization with the Unicode CLDR

05bab33cfd102c84f045838aa4e05bec?s=47 Nova Patch
August 18, 2015

Localization with the Unicode CLDR

Video and notes: http://patch.codes/talks/localization-with-the-unicode-cldr/

Unicode CLDR is quickly becoming the de facto locale standard with widespread use among companies including Google, Apple, and IBM; projects ranging from Linux distributions to Wikipedia; and increasing support in many programming languages. This talk will provide an introduction to software localization with the CLDR, highlight popular CLDR-based open source libraries in a variety of programming languages, and demonstrate how Shutterstock uses and contributes to them.

Presented at:
◦  2015-08-18: NY Tech Localization Meetup, New York, NY
◦  2015-07-22: OSCON, Portland, OR
◦  2014-06-26: Open Source Bridge, Portland, OR
◦  2014-06-23: YAPC::NA, Orlando, FL
◦ 2014-05-03: DC–Baltimore Perl Workshop, Silver Spring, MD

05bab33cfd102c84f045838aa4e05bec?s=128

Nova Patch

August 18, 2015
Tweet

Transcript

  1. Unicode Beyond Just Characters Localization with the CLDR

  2. Unicode Beyond Just Characters Nova Patch @novapatch Shutterstock

  3. None
  4. ぷ Ꮨ ⇱ K ㋻

  5. Ꙃ २ ௲

  6. ⇱ ⤳ ⪷ ௲ २ ൪ G K ж Ꙃ

    ﲵ Ꮨ 얜 ぷ ㋻ 森
  7. → g حض ← ﲵ ㋻ →ワ

  8. → g ﲵ ← حض ㋻ →ワ

  9. → g ﲵ ← حض ㋻ →ワ

  10. Unicode CLDR

  11. i18n vs. L10n

  12. None
  13. None
  14. None
  15. None
  16. None
  17. PyICU Python package

  18. from icu import Locale locale = Locale('fr')

  19. from icu import Locale locale = Locale('fr') Locale('en-US').getDisplayLanguage(locale)

  20. from icu import Locale locale = Locale('fr') Locale('en-US').getDisplayLanguage(locale) anglais

  21. from icu import Locale locale = Locale('fr') Locale('en-US').getDisplayCountry(locale) États-Unis

  22. for code in Locale.getISOCountries():

  23. for code in Locale.getISOCountries(): country = Locale('', code)

  24. for code in Locale.getISOCountries(): country = Locale('', code) countries.append(country.getDisplayCountry(locale))

  25. for code in Locale.getISOCountries(): country = Locale('', code) countries.append(country.getDisplayCountry(locale)) Andorre

    Émirats arabes unis Afghanistan Antigua-et-Barbuda Anguilla
  26. from icu import Locale, Collator locale = Locale('fr')

  27. from icu import Locale, Collator locale = Locale('fr') collator =

    Collator.createInstance(locale)
  28. from icu import Locale, Collator locale = Locale('fr') collator =

    Collator.createInstance(locale) countries = sorted(countries, key=collator.getSortKey)
  29. from icu import Locale, Collator locale = Locale('fr') collator =

    Collator.createInstance(locale) countries = sorted(countries, key=collator.getSortKey) Afghanistan Afrique du Sud Albanie Algérie Allemagne
  30. twitter_cldr Ruby gem

  31. require 'twitter_cldr'

  32. require 'twitter_cldr' DateTime.now.localize(:ja).to_full_s

  33. require 'twitter_cldr' DateTime.now.localize(:ja).to_full_s 2014 年 6 月 26 日木曜日 14

    時 30 分 00 秒 UTC +00:00
  34. require 'twitter_cldr' DateTime.now.localize(:es).to_full_s jueves, 26 de junio de 2014, 14:30:00

    (UTC +00:00)
  35. require 'twitter_cldr' DateTime.now.localize(:es).to_long_s 26 de junio de 2014, 14:30:00 UTC

  36. require 'twitter_cldr' DateTime.now.localize(:es).to_medium_s 26/6/2014 14:30:00

  37. require 'twitter_cldr' DateTime.now.localize(:es).to_short_s 26/6/14 14:30

  38. require 'twitter_cldr' DateTime.now.localize(:es) .to_additional_s('yQQQQ') 2.º trimestre de 2014

  39. require 'twitter_cldr' DateTime.now.localize(:es) .to_additional_s('yQQQ') T2 2014

  40. require 'twitter_cldr' 1234.5.localize(:es).to_s 1 234,5

  41. CLDR::Number Perl CPAN module

  42. $cldr = CLDR::Number->new(locale => 'es');

  43. $cldr = CLDR::Number->new(locale => 'es'); $decf = $cldr->decimal_formatter;

  44. $cldr = CLDR::Number->new(locale => 'es'); $decf = $cldr->decimal_formatter; say $decf->format(1234.5);

  45. $cldr = CLDR::Number->new(locale => 'es'); $decf = $cldr->decimal_formatter; say $decf->format(1234.5);

    1 234,5
  46. $decf->locale('es-MX'); say $decf->format(1234.5); 1,234.5

  47. $decf->locale('ar'); say $decf->format(1234.5); ١٬٢٣٤٫٥

  48. $decf->locale('bn'); say $decf->format(123000); ১,২৩,০০০

  49. $decf->locale('bn'); say $decf->format(12300000); ১,২৩,০০,০০০

  50. $perf = $cldr->percent_formatter( locale => 'tr' );

  51. $perf = $cldr->percent_formatter( locale => 'tr' );

  52. $perf = $cldr->percent_formatter( locale => 'tr' ); say $perf->format(0.05);

  53. $perf = $cldr->percent_formatter( locale => 'tr' ); say $perf->format(0.05); %5

  54. $perf->locale('ar'); say $perf->format(0.05); ٥٪

  55. $perf->locale('fr'); say $perf->format(0.05); 5 %

  56. $perf->permil(1); say $perf->format(0.05); 50 ‰

  57. $curf = $cldr->currency_formatter( locale => 'en', currency_code => 'USD', );

  58. $curf = $cldr->currency_formatter( locale => 'en', currency_code => 'USD', );

  59. $curf = $cldr->currency_formatter( locale => 'en', currency_code => 'USD', );

    say $curf->format(9.99);
  60. $curf = $cldr->currency_formatter( locale => 'en', currency_code => 'USD', );

    say $curf->format(9.99); $9.99
  61. $curf->locale('en-CA'); say $curf->format(9.99); US$9.99

  62. $curf->locale('fr-CA'); say $curf->format(9.99); 9,99 $US

  63. $curf->locale('fr-CA'); $curf->currency_code('CAD') say $curf->format(9.99); 9,99 $

  64. $curf->locale('bn'); $curf->currency_code('INR'); say $curf->format(123000); ১,২৩,০০০.০০₹

  65. $decf->locale('en'); translate( '[_1]–[_2] of [_3]', $decf->format(1), $decf->format(25), $decf->format(1500), );

  66. $decf->locale('en'); translate( '[_1]–[_2] of [_3]', $decf->format(1), $decf->format(25), $decf->format(1500), ); 1–25

    of 1,500
  67. $decf->locale('en'); translate( '[_1] of [_2]', $decf->range(1, 25), $decf->format(1500), ); 1–25

    of 1,500
  68. $decf->locale('ja'); translate( '[_1] of [_2]', $decf->range(1, 25), $decf->format(1500), ); 1

    ~ 25 の 1,500
  69. $decf->locale('ja'); $decf->numbering_system('fullwide'); translate( '[_1] of [_2]', $decf->range(1, 25), $decf->format(1500), );

    1~25の1 , 500
  70. $decf->locale('ja-u-nu-fullwide'); translate( '[_1] of [_2]', $decf->range(1, 25), $decf->format(1500), ); 1~25の1

    , 500
  71. Libraries C/C++ ICU4C Java ICU4J

  72. Libraries Ruby cldr twitter-cldr-rb Misc. RubyGems

  73. Libraries Ruby cldr twitter-cldr-rb Misc. RubyGems Perl Misc. CPAN

  74. Libraries Ruby cldr twitter-cldr-rb Misc. RubyGems Perl Misc. CPAN Go

    text/cldr Misc.
  75. Libraries JavaScript cldr.js twitter-cldr-js twitter-cldr-npm Globalize

  76. ICU4C Wrappers Python PyICU PHP intl Erlang i18n

  77. None
  78. Questions? Nova Patch @novapatch Shutterstock

  79. Thank you! Nova Patch @novapatch Shutterstock