WordCamp Geneva: Recent I18N Improvements in WordPress

WordCamp Geneva: Recent I18N Improvements in WordPress

Slides for my presentation at WordCamp Geneva, Switzerland, on November 18th, 2016.

5253258c79d25b02f51e0ac55e30cf69?s=128

Pascal Birchler

November 18, 2016
Tweet

Transcript

  1. Internationalization Improvements in WordPress 4.6 and Beyond

  2. Pascal Birchler
 @swissspidy

  3. Language Packs, the Early Days

  4. Automatic Updates

  5. None
  6. Change Your Mind

  7. None
  8. Language Packs for Plugins and Themes

  9. WordPress 4.6

  10. Localized Datepicker

  11. None
  12. Language Packs More Important Than Ever

  13. Loading Translations in Different Order

  14. load_plugin_textdomain( 'myplugin', false, 'languages' )

  15. wp-content/plugins/myplugin/ languages/… ! wp-content/languages/plugins/…

  16. wp-content/languages/plugins/… ! wp-content/plugins/myplugin/ languages/…

  17. Just-in-time Loading for Translations

  18. wp-content/languages

  19. // Do stuff. _e( 'Hello World’, 'myplugin' ); // …Magic

    happens… // Prints: Hallo Welt
  20. wp-content/languages/plugins/myplugin-de_DE.mo

  21. Good bye, load_plugin_textdomain()

  22. WordPress 4.7

  23. User Admin Language

  24. None
  25. None
  26. Back End: Français Front End: English

  27. None
  28. Locale Switching

  29. switch_to_locale()

  30. $switched = switch_to_locale( get_user_locale() ) // Do stuff. if (

    $switched ) { restore_previous_locale(); }
  31. Send Emails In the User’s Language

  32. What About the Admin Toolbar?

  33. None
  34. Beyond

  35. Preferred Languages

  36. None
  37. JavaScript Internationalization

  38. // PHP: wp_localize_script( 'myplugin-script', '_myPluginL10n', array( 'helloWorld' => __( 'Hello

    World','myplugin' ) ) ); // JS: alert( _myPluginL10n.helloWorld );
  39. if ( 1 == number ) { use( _myPluginL10n.singularString );

    } else { use( _myPluginL10n.pluralString ); }
  40. wp.i18n.__( 'Hello World' )

  41. wp-content/languages/plugins/myplugin-de_DE.json

  42. Good bye, wp_localize_script()

  43. User Timezones

  44. None
  45. Questions?

  46. Thanks!