Skip to main content

GET ALL WORDPRESS THEMES - ONLY €59.00 (15 WordPress Pixelemu themes) Read more

WordPress Basics Documentation

How to translate WordPress theme.

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.

Połączmy się:

INDICO S.C.

ul. Przyjaźni 9, 84-215 Gowino, registered in Centralna Ewidencja i Informacja o Działalnosci Gospodarczej
NIP/VATID: PL5882424318

Copyright © 2009-2021 Pixelemu.com All rights reserved.