Upgrade to Pro — share decks privately, control downloads, hide ads and more …

On Internationalization and Localization

On Internationalization and Localization

Reaching out to the local PHP community in Istanbul, I talked about the importance of internationalization (I18N) and localization (L10N) at PHPKonf.

I18N and L10N have a massive impact on user acceptance and usability. I highlight existing tools, interfaces, and best practices to get internationalization right in the UIs we create and the code we write.

In this presentation I show why English ≠ English, why you should not use flags for language switchers, and how you can implement I18N best practices in your development and design workflow.

5253258c79d25b02f51e0ac55e30cf69?s=128

Pascal Birchler

May 21, 2018
Tweet

Transcript

  1. Internationalization and Localization PHPKonf 2018

  2. Pascal Birchler
 @swissspidy

  3. Why Internationalization?

  4. Internationalization is not an afterthought

  5. The process of creating a product in such a way

    that it can be easily adapted to specific local languages and cultures Internationalization (I18N)
  6. The process of adapting a product or service to a

    particular language, culture, and desired local “look-and-feel.” Localization (L10N)
  7. “Localization is like translation but with a cultural twist” Localization

  8. Locales

  9. Locale ≠ Language

  10. American English ≠ British English

  11. Flag ≠ Language

  12. None
  13. None
  14. flagsarenotlanguages.com

  15. Dates

  16. None
  17. 12/05/2018

  18. None
  19. None
  20. Numbers

  21. 123 456.99 123,456.99 123’456.99 123.456,99

  22. Right to Left Icons Symbols Puns Timezones Legal Currencies Numbers

    Formal/Informal Support Units Idioms Temperature
  23. Dealing with Locales

  24. Locale Detection

  25. example.com/tr/blog

  26. None
  27. Accept-Language: es, en-gb;q=0.8, en;q=0.7

  28. None
  29. Internationalization in User Interfaces

  30. “Our target audience does not mind an English-only user interface.”

  31. Symbols ✅ ⭕

  32. None
  33. None
  34. Personal Names

  35. Unicode

  36. David Lloyd George

  37. Lang Leyen Little Lovett von der

  38. Implications for Field Design

  39. None
  40. None
  41. None
  42. None
  43. Left-to-Right Right-to-Left

  44. None
  45. None
  46. None
  47. Internationalization in Development

  48. None
  49. Pick a Technology

  50. None
  51. <xliff version="1.2"> <file source-language="en" target-language="en" ...> <body> <trans-unit id="title_hello_world"> <source>title.hello_world</source>

    <target>Hello World</target> </trans-unit> </body> </file> </xliff>
  52. string gettext ( string $message )

  53. string gettext ( string $message ) translations.pot tr_TR.po tr_TR.mo

  54. String Extraction

  55. function translateIt( $str ) { // Do something. gettext( $str

    ); } gettext( 'Foo' ); ✅ translateIt( 'Bar' ); ❌ gettext( 'Baz' ); ✅
  56. $foo = 'Hello World'; gettext( $foo ); ❌

  57. echo $num . gettext( ' items' ) ❌

  58. if ( $num == 1 ) printf( __( '%d item'

    ), $num ) else printf( __( '%d items' ), $num )
  59. printf( ngettext( '%d item', '%d items', $num ), $num )

  60. printf(_n('%d item', '%d items', 1), 1) printf(_n('%d item', '%d items',

    2), 2) printf(_n('%d item', '%d items', 5), 5)
  61. Beyond Numbers

  62. gettext( 'They play football' )

  63. MessageFormatter::formatMessage( "en_US", "{gender, select, ". "female {She plays football}". "male

    {He plays football}". "other {They play football}". "}", ['gender' => 'female' ] )
  64. Gettext vs. MessageFormat vs. ?

  65. Resources

  66. cldr.unicode.org

  67. w3.org/internationalization

  68. Localization Management POEditor LingoHub Poedit Transifex GlotPress PhraseApp

  69. icu-project.org

  70. Conclusion

  71. 1. Don’t make assumptions

  72. 2. Understand cultural values

  73. 3. i18n from the beginning

  74. 4. Don’t reinvent the wheel

  75. Thank You.