I translated all my theme strings and saved in .po and .mo files. I tested the implementation and it works fine, however I'm not sure how to let users choose their own language.

Are there any built-in functions to do this? How do I do it?

  • Language of whole site? Of front end? Registered users or any visitors? There is quite a range of things that might be required with languages, please clarify what exactly do you mean.
    – Rarst
    Commented Mar 11, 2014 at 21:03
  • For any visitors Commented Mar 12, 2014 at 0:44

3 Answers 3


Add filter in your child theme like this

add_filter( 'locale', 'set_my_locale' );
function set_my_locale( $lang ) {
  if ( 'gl' == $_GET['language'] ) {
    // set to Greenlandic
    return 'ka_GL';
  } else {
    // return original language
    return $lang;

You can create the languages dropdown on front-end or any settings on backend where user can easily switch. Then get the selected lang in $_GET variable and return that lang.


There are two types of translations in the WordPress website:

  1. Label Translation in WordPress Core and Theme, for that gettext technique is useful (as mentioned by you .po and .mo files)
  2. Content Translations for that you will need to add multi-lingual plugin to handle such feature. Good Example of such plugin are:


Use a multilingual plugin like Polylang

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.