translating wordpress themes and plugins wordcamp bhopal 2015

21
و ل ی ہ وں ہ ں ی م ل ٹ ا ےپ س ے ت ک س ھ ڑ پ ہ ی م ت ا ی ک و ہ

Upload: swapnil-patil

Post on 13-Apr-2017

55 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Translating WordPress themes and plugins WordCamp Bhopal 2015

ہیلوہوں میںپاٹل سے

ہو سکتے پڑھ یہ تم کیا

Page 2: Translating WordPress themes and plugins WordCamp Bhopal 2015

여보세요 나는한국에서내이름을작성하는

방법을잘모릅니다 당신이이것을읽을수있습니까 ?

Page 3: Translating WordPress themes and plugins WordCamp Bhopal 2015

Swapnil V. Patil

Developer & Designer@swapypatil

http://swapnilpatil.in

Page 4: Translating WordPress themes and plugins WordCamp Bhopal 2015

Translating WordPress Themes & Plugins

Page 5: Translating WordPress themes and plugins WordCamp Bhopal 2015

74,652,825Whoa! That’s a big number, aren’t you proud?

How many people around the globe use WordPress?

Page 6: Translating WordPress themes and plugins WordCamp Bhopal 2015

“According to the WordPress Survey, two-thirds of WordPress users live outside the US.That’s a lot of people who probably speak English as a

second language – and also people who develop websites for those who might not speak English at all.

Page 7: Translating WordPress themes and plugins WordCamp Bhopal 2015

GNU gettext frameworkA theme should be localized using the GNU gettext framework. In other words, the theme should be ready to be translated.Open up the Theme’s zip file & find the language folder. It should contain a POT file.WordPress uses the GNU gettext localization framework for translation.

Page 8: Translating WordPress themes and plugins WordCamp Bhopal 2015

Understanding Localization FrameworkWordPress uses the GNU gettext localization framework for translation and there are three types of files used in the framework:

1.POT2.PO3.MO

Page 9: Translating WordPress themes and plugins WordCamp Bhopal 2015

The POT filePOT (Portable Object Template) files: The first step in the translation process is using a program to search through the WordPress source code to pick out text passed into a __() or __e() function, generating a POT file. This file will contain all the text available for translation.

GOOD THING!Most of the themes already include this file!

Page 10: Translating WordPress themes and plugins WordCamp Bhopal 2015

The PO filePO (Portable Object) files: The second step involves translating the text in a POT file into the target language, saving both English and translator messages in a PO file.

Page 11: Translating WordPress themes and plugins WordCamp Bhopal 2015

The MO fileMO (Machine Object) files: In the last step, the PO file is converted into a machine readable format.

Page 12: Translating WordPress themes and plugins WordCamp Bhopal 2015

Include the load_theme_textdomain FunctionInclude the following function in your theme’s functions.php file to prep your theme for localization.load_theme_textdomain( 'yourtheme', templatepath.'/languages' );Change “yourtheme” to the name of your theme & “templatepath” to the location in your themes folder where you want to save your translation files.

Page 13: Translating WordPress themes and plugins WordCamp Bhopal 2015

Localize your themeThe next step is editing the text strings in each of your theme files and turning them into functions so they are translatable. To do this, you just need to wrap them in a __() function call.

Let’s see in next few slides how to do that.

Page 14: Translating WordPress themes and plugins WordCamp Bhopal 2015

<?php echo '<h2>Hello world!</h2>'; ?>

Becomes:

<?php echo '<h2>' . __('Hello world!', 'yourtheme') . '</h2>'; ?>

Page 15: Translating WordPress themes and plugins WordCamp Bhopal 2015

<?php echo 'Hello world!'; ?>

Becomes:

<?php _e('Hello world!', 'yourtheme'); ?>

If your code echoes the string to the browser, use the _e() function instead, so:

Page 16: Translating WordPress themes and plugins WordCamp Bhopal 2015

Hello world!

Becomes:

<?php _e('Hello world!','yourtheme')

You can also wrap regular text. For example:

Page 17: Translating WordPress themes and plugins WordCamp Bhopal 2015

Create a POT FileNow that your theme files are ready, the next step is to create a POT file.

POT files are often created by theme authors and delivered along with themes so translators can translate files using Poedit.

Page 18: Translating WordPress themes and plugins WordCamp Bhopal 2015

Setting Up Your Translated Theme in WordPressIn order to do this, you will need to FTP into your WordPress install and open up the wp_config file and add this line of code:define ('WPLANG', 'hi_IN');This line specifies Hindi for India, so you’ll need to replace hi_IN with your language and country code.

Page 19: Translating WordPress themes and plugins WordCamp Bhopal 2015

Translation Tips1.Don’t translate literally, translate

organically.2.Try to keep the same level of

formality (or informality).3.Don’t use slang or audience-

specific terms.4.Read other software’s

localizations in your language.

Page 20: Translating WordPress themes and plugins WordCamp Bhopal 2015

Thank You!

Page 21: Translating WordPress themes and plugins WordCamp Bhopal 2015

Questions?You can find me at

×@swapypatil on twitter×[email protected]