WordPress: How To Make Themes Support Multilanguage

WordPress is a powerful blogging platform. It can support creating and using custom theme. Sometimes, people need to create their theme multilanguage supported. In this post, the technique in order to achieve multilanguage is revealed.

  1. Create languages folder inside the theme folder. This folder will be used to saved translated text in .po and .mo files that created using POEdit.
  2. If you don’t have POEdit, you can download it here.
  3. Open POEdit, then click File, then click New..like image below.
    new poedit
  4. Then, on Translation Language window, choose the language you want the theme to be translated. For example, to Indonesian, see image below.
    translation language
  5. After that, save project in languages folder you have created before.
  6. Click Catalog, then click Properties. See image below.
    get properties
  7. In the Project Name and Version, fill in the project name, i.e. My Project.properties
  8. Choose Sources paths tab.
  9. In the Base path, fill in with ../, in the Paths section, add new Path .. See image below.source path
  10. Close properties window, then click save.
  11. In the theme, open functions.php, then located load_theme_textdomain(...) , then set it to be like this: load_theme_textdomain ('my-theme', get_template_directory() . '/languages');.
  12. After that, open all related files in theme, change all static texts into <?=__('Your Static Text')?>.
  13. Back to POEdit, click update button.
  14. All text that can be translated should can be seen. See image below.
    translated text
  15. Then, set the translation of each text.
  16. After all texts complete, click save.
  17. Open your wordpress link, and add ?lang=id at the link. All static texts should be translated now in Indonesia language based on translated text you set in POEdit.

Septu Jamasoka has written 23 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>