SlideShare a Scribd company logo
Sanjip Shah: Internationalizing and Localizing  WordPress Themes
INTERNATIONALIZING AND
LOCALIZING WORDPRESS THEME

              SANJIP SHAH
         Follow: @sanjipshah
   Contact: sanjiv.saha31@gmail.com
Overview
• Definition and Importance

• Overview of the Process
  – Load a text domain
  – WordPress functions
  – Poedit Software
  – Create a language file
  – Instruct WordPress to load the language file
WHAT?
• Internationalization(i18n)
    Process of making WordPress theme/plugin
    translation ready.


• Localization(l10n)
    Process of adapting internationalized WordPress
    theme/plugin for a specific language by translating
    text.
Why ?
• For Developers
   – Cover More Users



• For Users
   – Get other language




                           Figure: WordPress Sites in Different Languages
                              Source: http://en.wordpress.com/stats/
LOAD A TEXT DOMAIN



• First parameter:
  – Unique identifier
    (good practice to use theme’s name)

• Second parameter:
  – Folder of the language files.
PROCESSING TEXT MESSAGES
1. __() Function
   • Makes your text ready for translation and returning it for use
         in PHP.




2. _e() Function
   • Works similarly to echo in PHP by displaying text on the screen.
PROCESSING TEXT MESSAGES
3. esc_attr__() Function
    •   esc_attr__() is the internationalization equivalent of the esc_attr().
    •   esc_attr__() returns the translation for use in PHP.




4. esc_attr_e() Function
    •   Displays the translation on the screen.
PROCESSING TEXT MESSAGES
5. _x() Function
    •    Sometimes, you need to provide context for translations.




6. _ex() Function
    •    Works same as above except it displays the translation on the screen.
PROCESSING TEXT MESSAGES
7. _n() Function
  •   Differentiate between the singular and plural forms of text.




  •   We could also do as below for easiness.


  •   But does not work for all languages.

  •   For an example: In French. Using“journal(s)” wouldn ’t apply
      because the plural form of journal is journaux.
PROCESSING TEXT MESSAGES
• Other functions
  •   esc_html__()
  •   esc_html_e()
  •   esc_attr_x()
  •   esc_html_x()
  •   _nx()

  Resource: http://devotepress.com/community/part-i-
      internationalizing-and-localizing-wordpress-theme/
TRANSLATION FILES
•    There are 3 kind of files:
    1.   POT file
         – Contains a list of all translatable messages in our theme.

    2.   The .po file
         – Created when we translate a POT file to a particular language.
         – Contains Human Readable text.
         – Actually not necessary to run the translation.


    3.   The .mo file
         – The .mo is a binary file that is created automatically by
             translation software.
         – Not Human Readable.
CREATING POT FILE
Supported translation tools for WordPress, Some are listed below.
    1. Poedit: http://poedit.net

    2.   GlotPress: http://glotpress.org

    3.   Launchpad: https://translations.launchpad.net

    4.   Pootle: http://pootle.locamotion.org

    5.   Kbabel: http://i18n.kde.org

    6.   GNU Gettext: http://gnu.org/software/gettext
CREATING POT FILE
•   Open Poedit, and create a new catalog.
•   Fill in the project’s information in the “Project info” tab:




                    Fig 1. Poedit Project Info Tab
CREATING POT FILE
•   In “Paths” tab:




                      Fig 1. Poedit Paths Tab
CREATING POT FILE
•   In “Keywords” tab:




                   Fig 1. Poedit Keywords Tab

•   Click OK. Save the file and your pot file will be created.
CREATION OF .POT FILE




     Figure: POT file created.
THE POT FILE




Fig 1. The POT file
TRANSLATING THE POT FILE




 Figure: Translating a POT file anc creating .po and .mo file
CREATION OF .po and .mo FILE




     Figure: POT file, .po file and .mo file all created.
UPDATING THE CONFIGURATION FILE
  •   Open wp-config.php file.

  •   Replace



  •   With




Sources: http://svn.automattic.com/wordpress-i18n/
         http://codex.wordpress.org/Installing_WordPress_in_Your_Language
SO WHAT ABOUT PLUGINS?
• Loading Text Domain




• Rest is pretty much same.
SOME RESOURCES
•   http://wp.smashingmagazine.com/2011/12/29/internationalizing-
    localizing-wordpress-theme/Replace

•   http://devotepress.com/community/part-i-internationalizing-and-
    localizing-wordpress-theme/

•   http://codex.wordpress.org/I18n_for_WordPress_Developers

•   http://codex.wordpress.org/L10n:Localization_Teams

•   http://en.wikipedia.org/wiki/Internationalization_and_localization

•   http://devotepress.com/coding/data-validation-sanitization-
    wordpress-2/
Thank You!

Questions?

More Related Content

PDF
Vinay Paudel: Optimizing and Speeding up a WordPress site
PPTX
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
PPTX
Drupal Backend Performance and Scalability
PDF
Drupal Camp LA 2011: Typography modules for Drupal
PDF
Getting Under the Hood - WordPress File & Directory Structure
PDF
Get happy Editors with a suitable TYPO3 Backend Configuration
PDF
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
PDF
Hard Caching in TYPO3 - Developer Days in Malmø 2017
Vinay Paudel: Optimizing and Speeding up a WordPress site
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
Drupal Backend Performance and Scalability
Drupal Camp LA 2011: Typography modules for Drupal
Getting Under the Hood - WordPress File & Directory Structure
Get happy Editors with a suitable TYPO3 Backend Configuration
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Hard Caching in TYPO3 - Developer Days in Malmø 2017

What's hot (20)

PPTX
Presentation to SAIT Students - Dec 2013
PPT
Expert guide for PHP
PDF
Making Your Own URL Shortening Service
PDF
Cms & wordpress theme development 2011
PDF
WordPress At Scale. WordCamp Dhaka 2019
PDF
Debugging WordPress Performance using EasyEngine
PPTX
WordPress Hosting Best Practices - Do's and Don't s | WordPress Trivandrum
PPTX
3 Hacks to Improve WordPress Performance
ZIP
High Performance WordPress - WordCamp Jerusalem 2010
PPTX
WordPress CLI in-depth
PDF
All about word press
PDF
Optimizing wp
PDF
Wp3 refresh pgh
ODP
Drupal
PPS
Install WordPress Blogging Software with EasyPHP
PDF
Introduction to Web Designing
PDF
Mastering WordPress Vol.1
PPTX
Introduction to Wordpress
PPTX
Pragmatic plone projects
PPTX
Intro to advanced web development
Presentation to SAIT Students - Dec 2013
Expert guide for PHP
Making Your Own URL Shortening Service
Cms & wordpress theme development 2011
WordPress At Scale. WordCamp Dhaka 2019
Debugging WordPress Performance using EasyEngine
WordPress Hosting Best Practices - Do's and Don't s | WordPress Trivandrum
3 Hacks to Improve WordPress Performance
High Performance WordPress - WordCamp Jerusalem 2010
WordPress CLI in-depth
All about word press
Optimizing wp
Wp3 refresh pgh
Drupal
Install WordPress Blogging Software with EasyPHP
Introduction to Web Designing
Mastering WordPress Vol.1
Introduction to Wordpress
Pragmatic plone projects
Intro to advanced web development
Ad

Viewers also liked (7)

PDF
Mahadev Subedi: WordPress Security & Defense Mechanism
PDF
Pankaj Agrawal: eLearning on WordPress
PDF
Ujwal Thapa: WordPress as a Blogging Platform
PPTX
Jimba Tamang: 5 reasons why “Parallax Websites” are awesome and how to create...
PPTX
Simple Contact Us Plugin Development
PDF
Yalamber Subba: WordPress Jobs & Freelance Marketplaces
PDF
Parallax scrolling evaluation
Mahadev Subedi: WordPress Security & Defense Mechanism
Pankaj Agrawal: eLearning on WordPress
Ujwal Thapa: WordPress as a Blogging Platform
Jimba Tamang: 5 reasons why “Parallax Websites” are awesome and how to create...
Simple Contact Us Plugin Development
Yalamber Subba: WordPress Jobs & Freelance Marketplaces
Parallax scrolling evaluation
Ad

Similar to Sanjip Shah: Internationalizing and Localizing WordPress Themes (20)

PDF
Let's create a multilingual site in WordPress
PDF
Desktop Apps with PHP and Titanium
PPTX
Introduction to Python Programming
PPTX
Preparing an Open Source Documentation Repository for Translations
ODP
[EclipseCon France 2017] Eclipse Platform Generic Editor
PPTX
Php intro
PPTX
Learn PHP Lacture1
PPTX
An Introduction To Python - Python, Print()
PPTX
node_js.pptx
PPTX
From WordPress With Love
PDF
Managing Drupal interface translation
PPTX
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
PPT
Php intro
PPT
Php intro
PPT
Php intro
PPTX
Multi language for php with gettext
PDF
Desktop apps with node webkit
PDF
Building and deploying PHP applications with Phing
PPTX
Week 5
Let's create a multilingual site in WordPress
Desktop Apps with PHP and Titanium
Introduction to Python Programming
Preparing an Open Source Documentation Repository for Translations
[EclipseCon France 2017] Eclipse Platform Generic Editor
Php intro
Learn PHP Lacture1
An Introduction To Python - Python, Print()
node_js.pptx
From WordPress With Love
Managing Drupal interface translation
Chapter onehsfhjfgjhdjhdhfsGfhghsgasg (2).pptx
Php intro
Php intro
Php intro
Multi language for php with gettext
Desktop apps with node webkit
Building and deploying PHP applications with Phing
Week 5

More from wpnepal (11)

PDF
Utsav Singh Rathour: How, Why and Where to use WordPress multisite
PDF
Rabin Shrestha: Data Validation and Sanitization in WordPress
PDF
Roshan Bhattarai: Scaling WordPress for high traffic sites
PDF
Chandra Prakash Thapa: Make a WordPress Multisite in 20 mins
PDF
Jimba Tamang: Responsive and Retina Design
PDF
Bigyan Ghimire: GovtPress
PDF
Avinash Kundaliya: Javascript and WordPress
PDF
Kris Thapa: WP Ambulance
PDF
Chandra Maharzan: Making a successful career out of WordPress
PPT
WP Ambulance
PPTX
How to earn and maximize your earnings from your Blog - Pawan Agrawal
Utsav Singh Rathour: How, Why and Where to use WordPress multisite
Rabin Shrestha: Data Validation and Sanitization in WordPress
Roshan Bhattarai: Scaling WordPress for high traffic sites
Chandra Prakash Thapa: Make a WordPress Multisite in 20 mins
Jimba Tamang: Responsive and Retina Design
Bigyan Ghimire: GovtPress
Avinash Kundaliya: Javascript and WordPress
Kris Thapa: WP Ambulance
Chandra Maharzan: Making a successful career out of WordPress
WP Ambulance
How to earn and maximize your earnings from your Blog - Pawan Agrawal

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Cell Structure & Organelles in detailed.
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
GDM (1) (1).pptx small presentation for students
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Insiders guide to clinical Medicine.pdf
The Final Stretch: How to Release a Game and Not Die in the Process.
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis
Cell Structure & Organelles in detailed.
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
Open Quiz Monsoon Mind Game Final Set.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Open folder Downloads.pdf yes yes ges yes
102 student loan defaulters named and shamed – Is someone you know on the list?
GDM (1) (1).pptx small presentation for students
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Basic Mud Logging Guide for educational purpose
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf

Sanjip Shah: Internationalizing and Localizing WordPress Themes

  • 2. INTERNATIONALIZING AND LOCALIZING WORDPRESS THEME SANJIP SHAH Follow: @sanjipshah Contact: sanjiv.saha31@gmail.com
  • 3. Overview • Definition and Importance • Overview of the Process – Load a text domain – WordPress functions – Poedit Software – Create a language file – Instruct WordPress to load the language file
  • 4. WHAT? • Internationalization(i18n) Process of making WordPress theme/plugin translation ready. • Localization(l10n) Process of adapting internationalized WordPress theme/plugin for a specific language by translating text.
  • 5. Why ? • For Developers – Cover More Users • For Users – Get other language Figure: WordPress Sites in Different Languages Source: http://en.wordpress.com/stats/
  • 6. LOAD A TEXT DOMAIN • First parameter: – Unique identifier (good practice to use theme’s name) • Second parameter: – Folder of the language files.
  • 7. PROCESSING TEXT MESSAGES 1. __() Function • Makes your text ready for translation and returning it for use in PHP. 2. _e() Function • Works similarly to echo in PHP by displaying text on the screen.
  • 8. PROCESSING TEXT MESSAGES 3. esc_attr__() Function • esc_attr__() is the internationalization equivalent of the esc_attr(). • esc_attr__() returns the translation for use in PHP. 4. esc_attr_e() Function • Displays the translation on the screen.
  • 9. PROCESSING TEXT MESSAGES 5. _x() Function • Sometimes, you need to provide context for translations. 6. _ex() Function • Works same as above except it displays the translation on the screen.
  • 10. PROCESSING TEXT MESSAGES 7. _n() Function • Differentiate between the singular and plural forms of text. • We could also do as below for easiness. • But does not work for all languages. • For an example: In French. Using“journal(s)” wouldn ’t apply because the plural form of journal is journaux.
  • 11. PROCESSING TEXT MESSAGES • Other functions • esc_html__() • esc_html_e() • esc_attr_x() • esc_html_x() • _nx() Resource: http://devotepress.com/community/part-i- internationalizing-and-localizing-wordpress-theme/
  • 12. TRANSLATION FILES • There are 3 kind of files: 1. POT file – Contains a list of all translatable messages in our theme. 2. The .po file – Created when we translate a POT file to a particular language. – Contains Human Readable text. – Actually not necessary to run the translation. 3. The .mo file – The .mo is a binary file that is created automatically by translation software. – Not Human Readable.
  • 13. CREATING POT FILE Supported translation tools for WordPress, Some are listed below. 1. Poedit: http://poedit.net 2. GlotPress: http://glotpress.org 3. Launchpad: https://translations.launchpad.net 4. Pootle: http://pootle.locamotion.org 5. Kbabel: http://i18n.kde.org 6. GNU Gettext: http://gnu.org/software/gettext
  • 14. CREATING POT FILE • Open Poedit, and create a new catalog. • Fill in the project’s information in the “Project info” tab: Fig 1. Poedit Project Info Tab
  • 15. CREATING POT FILE • In “Paths” tab: Fig 1. Poedit Paths Tab
  • 16. CREATING POT FILE • In “Keywords” tab: Fig 1. Poedit Keywords Tab • Click OK. Save the file and your pot file will be created.
  • 17. CREATION OF .POT FILE Figure: POT file created.
  • 18. THE POT FILE Fig 1. The POT file
  • 19. TRANSLATING THE POT FILE Figure: Translating a POT file anc creating .po and .mo file
  • 20. CREATION OF .po and .mo FILE Figure: POT file, .po file and .mo file all created.
  • 21. UPDATING THE CONFIGURATION FILE • Open wp-config.php file. • Replace • With Sources: http://svn.automattic.com/wordpress-i18n/ http://codex.wordpress.org/Installing_WordPress_in_Your_Language
  • 22. SO WHAT ABOUT PLUGINS? • Loading Text Domain • Rest is pretty much same.
  • 23. SOME RESOURCES • http://wp.smashingmagazine.com/2011/12/29/internationalizing- localizing-wordpress-theme/Replace • http://devotepress.com/community/part-i-internationalizing-and- localizing-wordpress-theme/ • http://codex.wordpress.org/I18n_for_WordPress_Developers • http://codex.wordpress.org/L10n:Localization_Teams • http://en.wikipedia.org/wiki/Internationalization_and_localization • http://devotepress.com/coding/data-validation-sanitization- wordpress-2/