Supposing that I have two domains in my theme named "basic" and "advance".

Is it possible to load two different domains in my theme?

load_theme_textdomain( 'basic', TEMPLATEPATH.'/languages' );
load_theme_textdomain( 'advance', TEMPLATEPATH.'/languages' );
  • 1
    You can, however this will be incompatible with language packs coming in WordPress 3.7.
    – Otto
    Oct 20 '13 at 10:40
  • 1
    @Otto Please put that as a separate answer. Most people actually don't read comments and that info isn't trivial.
    – kaiser
    Oct 20 '13 at 12:21

Note that if you put your mo-files inside your theme’s directory, the same mo-file will be loaded for every theme textdomain. That is because a theme mo-file is based solely on the locale. For example:

load_theme_textdomain( 'basic', get_template_directory() . '/languages' );
load_theme_textdomain( 'advance', get_template_directory() . '/languages' );
load_theme_textdomain( 'whatever', get_template_directory() . '/languages' );

Given that “en_US” is your WPLANG locale, the code above will load wp-content/themes/your-theme/languages/en_US.mo three times! Bad because having the same mo-file imported multiple times only causes superfluous work. In that case you’re better off using a single theme domain.

However, if the wp-content/themes/your-theme/languages/en_US.mo does not exist, WordPress will have a look in the subdirectory “themes” of the default language directory and in that case it does take the domain into account as part of the filename. You can learn all that from a quick look at the load_theme_textdomain() function:

function load_theme_textdomain( $domain, $path = false ) {
    $locale = apply_filters( 'theme_locale', get_locale(), $domain );

    if ( ! $path )
        $path = get_template_directory();

    // Load the textdomain from the Theme provided location, or theme directory first
    $mofile = "{$path}/{$locale}.mo";
    if ( $loaded = load_textdomain($domain, $mofile) )
        return $loaded;

    // Else, load textdomain from the Language directory
    $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
    return load_textdomain($domain, $mofile);
  • You can add the text domain to the path: /languages/textdomain.
    – fuxia
    Oct 20 '13 at 10:52
  • Note: TEMPLATEPATH is slated for deprecation. Use get_template_directory_uri() instead. Oct 20 '13 at 12:55
  • -1, because load_theme_textdomain() is called by the Theme itself, and therefore the Theme can control the second function parameter. It doesn't have to be get_template_directory_uri() . '/languages/'. Oct 20 '13 at 12:57
  • 2
    @ChipBennett *_uri() is wrong anyway. :)
    – fuxia
    Oct 20 '13 at 15:03
  • @toscho there's an edit for that. Oct 20 '13 at 15:03

If you're creating this theme or plugin for inclusion in the official plugin or theme directories on WordPress.org, then you need to use the plugin or theme's slug as the text-domain. You cannot have multiple text domains, and the text domain cannot be anything other than the slug of the plugin or theme.

This is due to the new language pack support coming in 3.7. The language pack system will use the slug for the text domain, and won't work with anything else there.

  • Good to know, Otto; Thank you! So does this mean if we are not currently using the plugin slug for our text domain; it's gonna break in WordPress 3.7? Should I go back and recode my plugins? Thanks again.
    – josh
    Oct 20 '13 at 14:27
  • What exactly slug refers to? The Text Domain defined in the header of the plugin/theme?
    – brasofilo
    Oct 20 '13 at 14:42
  • I'm thinking the directory name of where the "(main).php" file resides?
    – josh
    Oct 20 '13 at 15:11
  • 2
    "Slug" is the directory name and the name of the plugin in the WordPress.org url. And it won't break, it just won't work with the new language packs feature unless they match up.
    – Otto
    Oct 20 '13 at 19:13

You certainly can.. however, you cannot use two separate language translations on a single text string.

For example, let's consider we have this text string somewhere on our page:

Hello World!

Now, if we want to set that up for language localization, here is what we do:

<?php _e('Hello World!', 'my_language_localization'); ?>

In your case, it could be either:

<?php _e('Hello World!', 'basic'); ?>


<?php _e('Hello World!', 'advance'); ?>

But, it is not possible to translate the single string into two localizations.

Also, when using a localization name; make it something unique so that it does not clash with other plugins/themes.


Since Wordpress 4, I suggest you create a simple plugin and "only" load the needed text domain. All strings in your Theme folders or templates or everywhere will be translated. Example:


Plugin Name: UA Translation UA Tiny select
Description: Translation for Theme templates outside the main text domain
Version: 1.0
Author: Jonas Lundman
Author URI: http://lundman.info
Text Domain: ua-tiny-select
Domain Path: /languages/

// Updated 2015 04 22 (21:00) 

function ua_load_plugin_textdomain_tiny_select() {
    load_plugin_textdomain( 'ua-tiny-select', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
add_action( 'plugins_loaded', 'ua_load_plugin_textdomain_tiny_select');


Works great for custom changes in woocommerce template files or Buddypress template files in your main domain Theme!

Remember to give the mo and po files the slug, in my case above:


And the folder Languages goes in your plugin folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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