Halloween Sale!

40% OFF on ALL!!
Use code: SPOOKY2020
5.00 (2 votes)
How to translate WordPress theme.

WordPress is the most popular CMS in the World and used by hundreds of millions users. How is it possible while many users use different native languages? That is easy, WordPress it self is translated to many languages and provides powerfull translation mechanism for themes and plugins.

How to translate WordPress theme?

You may translate WordPress theme language files or use WordPress translation plugins like WPML, Polylang, Loco Translate. I will describe how to translate WordPress theme manually.

Make sure that your theme and plugins are translation ready

All of our themes and plugins are translation ready :) But make sure that your theme have following function in your functions.php file:

load_theme_textdomain( 'PixelEmu', get_template_directory() . '/languages' );

Where PixelEmu is a unique identifier used in theme to translate strings and second parameters is location of language files.
What if theme or plugin is not translation ready?

You need to edit files and modify all strings.
Change:

<?php echo 'Some string'; ?>

to:

<?php echo __('Some string', 'PixelEmu'); ?>

or shorten version:

<?php _e('Some string', 'PixelEmu'); ?>

Naw you are ready to translate the theme.

Translate WordPress Theme

By default, our themes are provided with English language and uses system called: gettext for translations, localization and internationalization. What does it mean?
Developer / Client can use gettext calls for every translatable variables used in theme. Basicaly, this means you can translate every word used in theme files.
All calls are collected in PO (Portable Object) and MO (Machine Object) or POT (Portable Object Template) files.
You can simply edit PO or POT files with any editor in order to translate strings.

how to translate wordpress theme

But it is highly recommended to use a gettext editor like POEdit.

POEdit editor

First open POEdit

First open POEdit

Next open provided with theme PO/POT file localised in languages directory (eg. names: PixelEmu.po or en_GB.po)

PO/POT file

Translate strings :)

Save file and make sure MO file will be generated (you can check this in POEdit Preferences).

Next you need to rename file. The name of the translation file is important and should reflect your language and country code. For example, English translation save as en_GB, French translation save as fr_FR.po, Polish save as pl_PL etc.

Language Codes: http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Language-Codes
Country Codes: http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Country-Codes

translate wordpress theme

Move file to theme -> languages directory with your favourite FTP client.

Set your native language in WordPress

Go WordPress Admin Area -> Settings -> General -> Site Language
Choose your language and save settings.

Set your native language in WordPress

Results:

wordpress translation

Share your translation.

If you translate a theme or plugin, you can share your translation with community. Just contact with support and send PO/POT file to us. We will add these files during theme update and many people will be happy using your translation :)

Do you find this tutorial helpful? Please share! Thanks.

About the author

Artur Kaczmarek
WordPress and Joomla lover. Artur Kaczmarek works as a programmer and coder at Joomla-Monster.com and PixelEmu.com. Senior products quality reviewer. Recent passed level - specialist at accessible templates (WCAG/Section508). Artur graduated IT and econometrics. He is a passionate about new technologies and in particular everything related to programming and coding for content management systems.

Users' reviews

Total rating: 5.00 (2 votes) Log-in to add review

Sorry i meant the "contact page" not "comment page", is there a better forum for this discussion? i have tried to make a ticket but got no response.

Please try to use our ticket system: https://www.pixelemu.com/my-account/submit-ticket

We have not received your message in this system. Please try to check SPAM folder meanwhile.

ok, then i really wonder wich pot-files to translate, there are a lot of different ones in different directories, and shold i name the resulted files "sv_SE.mo" and "sv_SE.po" only? i have got it to work in the comment section only but then i have put in the string in the functions.php and i have edited all strings in all php-files in the theme directory from "PE-terraclassic" to "PixelEmu" and after doing that the comment page was translated! Why is that working?

Hi

If you want to translate PE Terraclassic theme and Terraclassifieds plugin you need to translate these files:
wp-content/themes/pe-terraclassic/languages/pe-terraclassic.pot
wp-content/plugins/pe-terraclassic-plugin/languages/pe-terraclassic-plugin.pot
wp-content/plugins/terraclassifieds/languages/terraclassifieds.pot

Translation should work without changing text domain to "Pixelemu".
You can use some more user friendly tool to translate themes and plugins like "Loco Translate" plugin.

Please also check this guide for Terraclassifieds: https://terraclassifieds.pixelemu.com/106-translating

5.00

I am using the terraclassic theme and i believe i have to edit all strings as mentionrd above, but doed that mean all ?php echo strings in all php files in that theme folder? I have not found a single one that looks simply like this:

Most of them have alot more info in them and most dont have: ' '. An most already have: ().

So how do i edit those and do i have to?

Hi

Thank you for contact.
If you are using the PE Terraclassic theme you don't need to do that. It's necessary for themes without translation feature.
Please use the POEdit tool to make a translation like in this tutorial. You don't need to edit any PHP files.

Best Regards
ML

INDICO S.C.

ul. Wałowa 10/3, 84-200 Wejherowo, registered in Centralna Ewidencja i Informacja o Działalnosci Gospodarczej
NIP/VATID: PL5882424318

Copyright © 2015-2019 PixelEmu.com All rights reserved.