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

Intro to I18N in code

Intro to I18N in code

Short introduction to writing code that can be easily translated in WordPress

Matthew Haines-Young

May 13, 2015


  1. How translation it works. • Uses the gettext libraries. •

    Wrap translatable strings in special gettext functions • Automated process - scans your code • Creates POT (Portable Objects Template) file with all translatable strings.
  2. Setup • Add the Text Domain to the theme/plugin header.

    • This is a unique identifier. • Use dashes not underscores
  3. Plurals • _n( $singular, $plural, $count, ‘text- domain’ ) •

    1st param: the singular form of the string • 2nd param: the plural form of the string • 3rd param: the count.
  4. Resources • VIDEO: Rules for WordPress i18n - http://wordpress.tv/2014/02/26/ samuel-otto-wood-on-internationalization-plugins-and-themes-for-the-

    whole-world/ • Otto on i18n - http://ottopress.com/2012/internationalization-youre- probably-doing-it-wrong/ • Plugin i18n - https://developer.wordpress.org/plugins/ internationalization/ • Theme i18n - https://developer.wordpress.org/themes/functionality/ internationalization/ • i18n quiz for developers: https://developer.wordpress.com/2015/04/23/ wordpress-developers-test-your-i18n-internationalization-knowledge/