Last Updated: February 25, 2016
·
800
· angezanetti

Translate a Wordpress theme

There is plenty of tutorial on how to translate a thème with creating a .po & .mo files. I will not create another one here, just check this one : http://www.appthemes.com/blog/how-to-translate-a-wordpress-theme/

But if you want to implement this translation in a brand new theme or i a theme which not support translation out of the box you'll need more than that.

Here is how to implement this:

Edit your functions.php file and add this small piece of code

function langage() {
    load_theme_textdomain( 'my_theme', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'so16309230_after_setup_theme' );

Then make sure that your style.css files contains the text domain declaration

Text Domain: my_theme

Refresh your site and you will the magic happens, front-end & back-end side !

Enjoy

1 Response
Add your response

over 1 year ago ·