Menu

Translating po files from scratch in a wp theme

You should utilize the software POEdit to translate your theme from scratch or replace/add new strings into the .po/.mo information. Right here is the software utilization tutorial: Translating_With_Poedit

There’s a plugin that may do the job for you: codestyling-localization

STEPS:

1. Load a textual content area for the theme.

add_action('after_setup_theme', 'my_theme_setup'); operate my_theme_setup()

2. Discover the messages that should be translated and course of them with the suitable WordPress operate.

_e(‘Good day person’,’mytheme’); the_content( __(‘Learn extra’,’mytheme’) );

three. Create language information. three.1 The POT file comprises an inventory of all translatable messages in our theme.

three.2 The .po file is created once we translate a POT file to a selected locale.

three.three The .mo is a binary file that’s created routinely by translation software program and isn’t human-readable.

four. Create the POT file with assist of a software referred to as PoEdit

four.1 Open Poedit, and create a brand new catalog. Fill within the mission’s info within the “Venture data” tab.

four.2 Present path to the theme and it’ll parse all of the textual content these must be translated. You have to present the key phrases we used within the theme __( and _e so it will possibly parse and create the POT for you.

four.three Now add the translated textual content for every string inside POT file and a .po file is created by setting the language code and nation code because the file title.

four.four Generate .mo file out of it. (When saving a .po file, Poedit will routinely create an .mo file, which is a binary file and isn’t human-readable.)

four.5 Instruct WordPress to allow the localization and to load the language information. Edit the wp-config.php file and edit this outline('WPLANG', 'en_GB');