@LisaSabinWilson - webdevstudios.com | December 7, 2013 Lisa Sabin-Wilson WordPress since 2003 Making a living on WP since 2005 Author: WordPress For Dummies @LisaSabinWilson
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Localization (l10n) The practice of translating an internationalized theme into a different language.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Internationalization (I18n) YOU ARE NOT ACTUALLY TRANSLATING IT. ! You are developing your theme to make it possible for someone else to translate it.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Text Domain
Defines which theme owns the translation-ready text and tells the GetText utility to return the translations only from the dictionary supplied with that name.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Text Domain *MOST* theme authors use the name of their theme as the text domain to make it easy to identify which theme the language files belong to.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Theme Functions Define the text domain in your Theme Functions file. This tells WordPress where your theme stores the language files and what the text domain for your theme is.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Theme Functions - 3.7 WordPress 3.7 supports language packs. ! Include headers in your theme (or plugin) in order for translations to be most effective.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Theme Functions - 3.7 The text domain should be IDENTICAL to the plugin folder name. If your theme is: /themes/my-theme Your text domain: my-theme
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Theme Functions - 3.7 The Domain Path is optional. If you want to include your own translations files, use it - otherwise it will use the language pack system.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Without these functions, the GetText localization utility will ignore the text and those text strings will not be translatable on the fly.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Do not place PHP variables inside a translation function (Thanks Otto!) Not this: $string = __("You have $number tacos", 'plugin- domain'); ! Do this: $string = sprintf( __('You have %d tacos', 'plugin-domain'), $number );
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Translation relies on looking up strings in a table and then translating them. The list of strings to be translated is built by an automated process. Some code scans your PHP code, without executing it, and pulls out all the __()’s it finds, then builds the list of strings to be translated. That scanning code cannot possibly know what is inside $string.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Do not put HTML markup inside your GetText functions. Translators should not have the ability to change your markup. Not this: WordSesh', 'text-domain'); ?> ! Do this:
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Mind your plurals! Use the _n function for this - it will use first string if the $number (third parameter to _n) is one, or the second one if it’s more than one. ! $string = sprintf( _n('You have %d beer.', 'You have %d beers.', $number, 'plugin-domain'), $number );
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Acknowledge international date formats by allowing users to set their own formats in Settings-->General in their Dashboard. Not this: the_time('F j, Y'); ! Do this: the_time( get_option('date_format') )
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips Google Fonts and other font packs Not all font packs are made equal. Some do not support cyrillic languages (Russian, Japanese, etc) or languages with western european characters (Polish, etc).
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips RTL (Right to Left) Support ! Some languages read/write right to left (RTL): Arabic, Hebrew, Urdu
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips RTL (Right to Left) Support - CSS ! Start by adding this to your body selector in your style-rtl.css:
@LisaSabinWilson - webdevstudios.com | December 7, 2013 i18n Tips RTL (Right to Left) Support - CSS ! Go through your CSS line by line to create RTL support for each selector.
! Some hints: http://codex.wordpress.org/Right-to- Left_Language_Support
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Language Files Once your theme is fully internationalized... ! Create a .pot file and include it in your /languages folder
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Language Files .pot stands for Portable Object Template. ! Contains a list of all translatable messages in your theme.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Language Files .po stands for Portable Object. ! Created when you translate a .pot file to a specific language - contains Human Readable text.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Language Files .mo stands for Machine Object. ! A binary file created automatically by translation software - - is NOT human readable.
@LisaSabinWilson - webdevstudios.com | December 7, 2013 Example fr_FR.po file Notice: the msgstr string is filled in with the French translation of the msgid