Requirements for Wordpress theme localization setup
Ensure you have used _e()
, __()
, _x()
etc. functions in your theme. Use unique text domain as argument (for example, __('Poetry', 'myblogtextdomain')
)
Install Poedit, create new catalog (.po
file) and save it in [themename]/languages/ with locale name (ru_RU.po
, en_US.po
etc.). In catalog properties leave Language field empty, in Sources paths use ../../
as base path and theme name as a Paths field group entry
Use Update command in Poedit to scan theme files for strings to be translated
Translate these strings and save the file. Poedit will automatically create .mo
file
Upload them both (still to [themename]/languages)
Insert function that will load text domain in functions.php:
add_action('after_setup_theme', 'setup_textdomain');
function setup_textdomain(){
load_theme_textdomain('myblogtextdomain', get_template_directory() . '/languages');
}