SlideShare a Scribd company logo
WordPress
- Internationalization
- Localization
- Multilingual
(April 16, 2016)
Do
It
Right
Me and Company
Dat Hoang
Community & Support at OnTheGoSystems
Image credit: Denise VanDeCruze - OnTheGoSystems.
Me and Company
OnTheGoSystems
wp-types.comwpml.org icanlocalize.com
Main Content
● What are they?
● Internationalization
● Localization
● Multilingual (with WPML)
What are They?
Internationalization (i18n) is the process of
developing your theme/plugin language, so it can
easily be translated into other languages.
Localization (l10n) describes the subsequent
process of translating an internationalized
theme/plugin.
Multilingual means there are more than one
language in sites.
Internationalization (1)
Wrong
echo 'WordPress is the best!';
Right (use gettext functions)
echo __( 'WordPress is the best!', 'my-text-domain' );
Wrong (don’t be clever!)
__( 'Translate me.' , $my_text_domain );
Right (no variable, constant… for text domains)
__( 'Translate me.' , 'my-text-domain' );
Internationalization (2)
Basic functions:
● __(), _e()
● _x(), _ex() - Disambiguation by context
_x( 'Post', 'noun', 'my-text-domain' );
_x( 'Post', 'verb', 'my-text-domain' );
● _n(), _nx() - Plural/singular nouns
sprintf(
_n( '%s star', '%s stars', $rating, 'text-domain' ),
$rating );
● _n_noop(), _nx_noop(), translate_nooped_plural()
Internationalization (3) - JavaScript
function add_my_script() {
// Register the script
wp_register_script( 'some_handle',
get_template_directory_uri() . '/custom.js' );
// Localize the script with new data
$translation_array = array (
'some_string' => __( 'Some string to translate',
'text-domain' ),
'a_value' => '10'
);
wp_localize_script( 'some_handle', 'object_name',
$translation_array );
// Enqueued script with localized data.
wp_enqueue_script( 'some_handle' );
}
add_action( 'wp_enqueue_scripts', 'add_my_script' );
Internationalization (4) - JavaScript
custom.js
<script>
// alerts 'Some string to translate'
alert( object_name.some_string);
</script>
HTML:
<script type='text/javascript'>
/* <![CDATA[ */
var object_name = {"some_string":"Some string to
translate","a_value":"10"};
/* ]]> */
</script>
Internationalization (5)
Date and number functions:
- number_format_i18n()
- date_i18n()
Escape functions:
esc_html__()
esc_html_e()
esc_html_x()
esc_attr__()
esc_attr_e()
esc_attr_x()
Internationalization (6)
Load .mo files:
function my_plugin_load_plugin_textdomain() {
load_plugin_textdomain( 'text-domain', FALSE,
basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded',
'my_plugin_load_plugin_textdomain' );
Last but not least: original language = ENGLISH
Localization (1)
File Types
● POT (Portable Object Template)
#: plugin-name.php:123
msgid "Page Title"
msgstr ""
● PO (Portable Object)
● MO (Machine Object)
Localization (2)
Generates POT / PO / MO files
● Plugin Repository Admin Tools
● WordPress i18n tools
● Grunt
● WPML String Translation
● MO files:
○ msgfmt -o filename.mo filename.po
○ Online tools
○ grunt-po2mo
Localization (3)
Translate
● Poedit
● Plugins:
○ Loco Translate
○ WPML String Translation
● Google Translator Toolkit
● translate.wordpress.org
Localization (4)
Feel localization!
● Settings > General > Site language
● Put the correct folders
○ wp-content/languages/plugins/text-domain-vi_VN.mo
○ wp-content/plugins/my-plugin/languages/text-domain-vi_VN.mo
Localization (5)
Contribute: Everyone can help
● https://wpvi.wordpress.com/
● https://translate.wordpress.
org/locale/vi/default/wp/dev
● https://translate.wordpress.org/projects/wp-
plugins/woocommerce
Multilingual (with WPML)
● Gettext strings
● Options (saved in wp_options)
● Content (posts, categories, menus)
● WooCommerce
● Common issues
Multilingual (1)
Gettext strings
● Important: theme and plugins are ready for
internalization/localization.
● Use .mo files
● Use WPML > String Translation
Multilingual (2)
Options - translate in WPML String Translation
● Automatically: wpml-config.xml
● Manually: adding strings in wp-admin
Multilingual (3)
Content - posts
Multilingual (4)
Content - categories
Multilingual (5)
Content - menus
Multilingual (6)
WooCommerce - install WCML
Multilingual (7)
Common issues:
● Translate custom strings
- wpml_register_single_string
- wpml_translate_single_string
● wp_query($args) or get_posts($args) doesn’t
filter out correct posts IDs for the current
language
- add "suppress_filters=0" to arguments.
Multilingual (8)
Common issues:
● A custom post is different in a second
language
$post = get_post(
apply_filters( 'wpml_object_id', $post->ID, 'cpt' ) );
● A custom taxonomy ID is different in a second
language
$tax_id =
apply_filters( 'wpml_object_id', $tax_id, 'tax' );
Discussion
Image credit: http://sweetclipart.com/diverse-people-raising-hands-968
Useful Links
1. https://developer.wordpress.
org/plugins/internationalization/localization
2. https://developer.wordpress.
org/plugin/internationalization/how-to-internationalize-your-
plugin
3. https://docs.woothemes.com/document/woocommerce-
localization/
4. https://wpml.org/documentation/related-
projects/woocommerce-multilingual/
5. https://wpml.org/documentation/support/debugging-theme-
compatibility/
6. https://wpml.org/documentation/translating-your-contents/
Big Thanks!
Dat Hoang
Community & Support
E: dat.h@icanlocalize.com
W: wpml.org | wp-types.com | icanlocalize.com
Saigon, April 16, 2016

More Related Content

PDF
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
PPTX
WordPress internationalization, localization, and multilingual
PDF
Accessibility in the age of the headless CMS
PDF
What is the Responsibility of Plugin Developers?
PDF
Managing a Local WordPress Community, WordCamp Europe 2016
PPTX
A journey to be a successful web developer
PDF
WordPress Multilingual: Benefits and Considerations
PDF
Intro to web
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
WordPress internationalization, localization, and multilingual
Accessibility in the age of the headless CMS
What is the Responsibility of Plugin Developers?
Managing a Local WordPress Community, WordCamp Europe 2016
A journey to be a successful web developer
WordPress Multilingual: Benefits and Considerations
Intro to web

What's hot (18)

DOC
Resume
PDF
Web Application Intro for RailsGirls Berlin May 2013
PDF
Going Global - WordPress Multilingual
PDF
CVsnig (1)
ODP
Profiling PHP & Javascript
PPTX
Php website developers massachusetts
PDF
Bentobox exercise
PDF
Multiple countries & multilingual e-commerce platforms using Drupal
PDF
wcdk - Making your WordPress Multilingual
PDF
Using Drupal to publish Web, Print and Mobile from same CMS
PPTX
Java script
PPTX
Learn web development: Front-end vs Back-end development
PDF
Setting up a local web server for WordPress
PPTX
Ppt full stack developer
PPTX
Basic introduction of PHP
PPTX
Web Design class( HTML-01)
PDF
Is php dying?
PPTX
Getting WordPress to speak your langauge
Resume
Web Application Intro for RailsGirls Berlin May 2013
Going Global - WordPress Multilingual
CVsnig (1)
Profiling PHP & Javascript
Php website developers massachusetts
Bentobox exercise
Multiple countries & multilingual e-commerce platforms using Drupal
wcdk - Making your WordPress Multilingual
Using Drupal to publish Web, Print and Mobile from same CMS
Java script
Learn web development: Front-end vs Back-end development
Setting up a local web server for WordPress
Ppt full stack developer
Basic introduction of PHP
Web Design class( HTML-01)
Is php dying?
Getting WordPress to speak your langauge
Ad

Similar to WordPress Internationalization, Localization and Multilingual - Do It Right (20)

PPTX
WordPress Internationalization and Localization - WordPress Translation Day 3...
PDF
Multilingual WordPress
PDF
Multilingual WordPress (WordCamp Toronto 2014)
PPTX
How to make multilingual plugins and themes
PDF
WordPress Theme Workshop: Internationalization
PPTX
MAKE YOUR THEMES AND PLUGINS READY FOR TRANSLATION
PPTX
WordPress Theme & Plugin i18n & L10n
PPTX
Writing Multilingual Plugins and Themes - WCMIA 2016
PPTX
Internationalizing and localizing wordpress theme
PDF
Sanjip Shah: Internationalizing and Localizing WordPress Themes
PPTX
Going Global WordPress Multilingual
PDF
Creating Multilingual WordPress Websites
PPTX
Multilingual content with WordPress
PPTX
Translating WordPress themes and plugins WordCamp Bhopal 2015
PPTX
Creating Multilingual WordPress Websites
PDF
10 common mistakes WordPress developers make when building multilingual sites
PDF
Internationalization: Preparing Your WordPress Theme for the Rest of the World
PPT
WordCamp Lancaster 2014: A11Y? I18N? L10N? UTF8? WTF?
PDF
i18n for Plugin and Theme Developers, WordCamp Milano 2016
PDF
Let's create a multilingual site in WordPress
WordPress Internationalization and Localization - WordPress Translation Day 3...
Multilingual WordPress
Multilingual WordPress (WordCamp Toronto 2014)
How to make multilingual plugins and themes
WordPress Theme Workshop: Internationalization
MAKE YOUR THEMES AND PLUGINS READY FOR TRANSLATION
WordPress Theme & Plugin i18n & L10n
Writing Multilingual Plugins and Themes - WCMIA 2016
Internationalizing and localizing wordpress theme
Sanjip Shah: Internationalizing and Localizing WordPress Themes
Going Global WordPress Multilingual
Creating Multilingual WordPress Websites
Multilingual content with WordPress
Translating WordPress themes and plugins WordCamp Bhopal 2015
Creating Multilingual WordPress Websites
10 common mistakes WordPress developers make when building multilingual sites
Internationalization: Preparing Your WordPress Theme for the Rest of the World
WordCamp Lancaster 2014: A11Y? I18N? L10N? UTF8? WTF?
i18n for Plugin and Theme Developers, WordCamp Milano 2016
Let's create a multilingual site in WordPress
Ad

More from Dat Hoang (7)

PDF
Gaining Customer Loyalty through Support - A Case Study on WPML Team
PDF
WordPress News and #SaigonWordPress 2015 - Saigon WordPress - Jan 17, 2015
PDF
WordPress Fresh News - Saigon WordPress - Nov 29, 2014
PDF
Gaining Customer Loyalty Through Support - A Case Study on WPML Team
PDF
WordPress and Opportunities for Students
PDF
Scaling WordPress - Project Lana WordPress Team
PDF
Introduction to WooCommerce
Gaining Customer Loyalty through Support - A Case Study on WPML Team
WordPress News and #SaigonWordPress 2015 - Saigon WordPress - Jan 17, 2015
WordPress Fresh News - Saigon WordPress - Nov 29, 2014
Gaining Customer Loyalty Through Support - A Case Study on WPML Team
WordPress and Opportunities for Students
Scaling WordPress - Project Lana WordPress Team
Introduction to WooCommerce

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
A Presentation on Artificial Intelligence
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Cloud computing and distributed systems.
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
NewMind AI Monthly Chronicles - July 2025
A Presentation on Artificial Intelligence
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Spectral efficient network and resource selection model in 5G networks
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Cloud computing and distributed systems.
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation

WordPress Internationalization, Localization and Multilingual - Do It Right

  • 1. WordPress - Internationalization - Localization - Multilingual (April 16, 2016) Do It Right
  • 2. Me and Company Dat Hoang Community & Support at OnTheGoSystems Image credit: Denise VanDeCruze - OnTheGoSystems.
  • 4. Main Content ● What are they? ● Internationalization ● Localization ● Multilingual (with WPML)
  • 5. What are They? Internationalization (i18n) is the process of developing your theme/plugin language, so it can easily be translated into other languages. Localization (l10n) describes the subsequent process of translating an internationalized theme/plugin. Multilingual means there are more than one language in sites.
  • 6. Internationalization (1) Wrong echo 'WordPress is the best!'; Right (use gettext functions) echo __( 'WordPress is the best!', 'my-text-domain' ); Wrong (don’t be clever!) __( 'Translate me.' , $my_text_domain ); Right (no variable, constant… for text domains) __( 'Translate me.' , 'my-text-domain' );
  • 7. Internationalization (2) Basic functions: ● __(), _e() ● _x(), _ex() - Disambiguation by context _x( 'Post', 'noun', 'my-text-domain' ); _x( 'Post', 'verb', 'my-text-domain' ); ● _n(), _nx() - Plural/singular nouns sprintf( _n( '%s star', '%s stars', $rating, 'text-domain' ), $rating ); ● _n_noop(), _nx_noop(), translate_nooped_plural()
  • 8. Internationalization (3) - JavaScript function add_my_script() { // Register the script wp_register_script( 'some_handle', get_template_directory_uri() . '/custom.js' ); // Localize the script with new data $translation_array = array ( 'some_string' => __( 'Some string to translate', 'text-domain' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array ); // Enqueued script with localized data. wp_enqueue_script( 'some_handle' ); } add_action( 'wp_enqueue_scripts', 'add_my_script' );
  • 9. Internationalization (4) - JavaScript custom.js <script> // alerts 'Some string to translate' alert( object_name.some_string); </script> HTML: <script type='text/javascript'> /* <![CDATA[ */ var object_name = {"some_string":"Some string to translate","a_value":"10"}; /* ]]> */ </script>
  • 10. Internationalization (5) Date and number functions: - number_format_i18n() - date_i18n() Escape functions: esc_html__() esc_html_e() esc_html_x() esc_attr__() esc_attr_e() esc_attr_x()
  • 11. Internationalization (6) Load .mo files: function my_plugin_load_plugin_textdomain() { load_plugin_textdomain( 'text-domain', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); } add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain' ); Last but not least: original language = ENGLISH
  • 12. Localization (1) File Types ● POT (Portable Object Template) #: plugin-name.php:123 msgid "Page Title" msgstr "" ● PO (Portable Object) ● MO (Machine Object)
  • 13. Localization (2) Generates POT / PO / MO files ● Plugin Repository Admin Tools ● WordPress i18n tools ● Grunt ● WPML String Translation ● MO files: ○ msgfmt -o filename.mo filename.po ○ Online tools ○ grunt-po2mo
  • 14. Localization (3) Translate ● Poedit ● Plugins: ○ Loco Translate ○ WPML String Translation ● Google Translator Toolkit ● translate.wordpress.org
  • 15. Localization (4) Feel localization! ● Settings > General > Site language ● Put the correct folders ○ wp-content/languages/plugins/text-domain-vi_VN.mo ○ wp-content/plugins/my-plugin/languages/text-domain-vi_VN.mo
  • 16. Localization (5) Contribute: Everyone can help ● https://wpvi.wordpress.com/ ● https://translate.wordpress. org/locale/vi/default/wp/dev ● https://translate.wordpress.org/projects/wp- plugins/woocommerce
  • 17. Multilingual (with WPML) ● Gettext strings ● Options (saved in wp_options) ● Content (posts, categories, menus) ● WooCommerce ● Common issues
  • 18. Multilingual (1) Gettext strings ● Important: theme and plugins are ready for internalization/localization. ● Use .mo files ● Use WPML > String Translation
  • 19. Multilingual (2) Options - translate in WPML String Translation ● Automatically: wpml-config.xml ● Manually: adding strings in wp-admin
  • 24. Multilingual (7) Common issues: ● Translate custom strings - wpml_register_single_string - wpml_translate_single_string ● wp_query($args) or get_posts($args) doesn’t filter out correct posts IDs for the current language - add "suppress_filters=0" to arguments.
  • 25. Multilingual (8) Common issues: ● A custom post is different in a second language $post = get_post( apply_filters( 'wpml_object_id', $post->ID, 'cpt' ) ); ● A custom taxonomy ID is different in a second language $tax_id = apply_filters( 'wpml_object_id', $tax_id, 'tax' );
  • 27. Useful Links 1. https://developer.wordpress. org/plugins/internationalization/localization 2. https://developer.wordpress. org/plugin/internationalization/how-to-internationalize-your- plugin 3. https://docs.woothemes.com/document/woocommerce- localization/ 4. https://wpml.org/documentation/related- projects/woocommerce-multilingual/ 5. https://wpml.org/documentation/support/debugging-theme- compatibility/ 6. https://wpml.org/documentation/translating-your-contents/
  • 28. Big Thanks! Dat Hoang Community & Support E: dat.h@icanlocalize.com W: wpml.org | wp-types.com | icanlocalize.com Saigon, April 16, 2016