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

GWTD: I18N Improvements in WordPress 4.6 And Beyond

GWTD: I18N Improvements in WordPress 4.6 And Beyond

Slides for my presentation at the 2nd Global WordPress Translation Day on November 12th, 2016.

5253258c79d25b02f51e0ac55e30cf69?s=128

Pascal Birchler

November 12, 2016
Tweet

More Decks by Pascal Birchler

Other Decks in Programming

Transcript

  1. Internationalization Improvements in WordPress 4.6 and Beyond

  2. Pascal Birchler
 @swissspidy

  3. First, Some History

  4. Language Packs

  5. Automatic Updates

  6. Language Chooser

  7. None
  8. Change Your Mind

  9. None
  10. Language Packs for Plugins and Themes

  11. WordPress 4.6

  12. Localized Datepicker

  13. None
  14. Bonus: wp_add_inline_script()

  15. Language Packs More Important Than Ever

  16. Loading Translations in Different Order

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

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

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

  20. On Demand Translations™

  21. Just-in-time Loading for Translations

  22. wp-content/languages

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

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

  25. Demo

  26. Good bye, load_plugin_textdomain()

  27. WordPress 4.7

  28. User Admin Language

  29. None
  30. None
  31. Back End: Español Front End: English

  32. None
  33. Locale Switching

  34. switch_to_locale()

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

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

  37. What About the Admin Toolbar?

  38. None
  39. Demo

  40. Beyond

  41. Preferred Languages

  42. None
  43. JavaScript Internationalization

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

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

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

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

  48. None
  49. Good bye, wp_localize_script()

  50. User Timezones

  51. None
  52. Open Floor

  53. Thanks!