Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/load theme textdomain


Loads the theme's translated strings.

If the current locale exists as a .mo file in the theme's root directory, it will be included in the translated strings by the $domain.

The .mo files must be named based on the locale exactly, sv_SE.mo for example.


<?php load_theme_textdomain$domain$path ?>


(string) (required) Unique identifier for retrieving translated strings.
Default: None
(unknown) (optional) The directory where the .mo file can be found (without the trailing slash).
Default: false

Return Values

This function return TRUE as textdomain well loaded, FALSE on failure.


1st example

The load_theme_textdomain() function should generally be called from within the after_setup_theme action hook.

add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_setup(){
    load_theme_textdomain( 'my-theme', get_template_directory() . '/languages' );

The .mo files must use language-only filenames, like languages/de_DE.mo in your theme directory.

Unlike plugin language files, a name like my_theme-de_DE.mo will NOT work. Although plugin language files allow you to specify the text-domain in the filename, this will NOT work with themes. Language files for themes should include the language shortcut ONLY.

2nd example

you can use this example if you wish to switch theme language using a variable passed within the URL, for example to load the Tamazikht language, your URL would look like; www.example.com/?l=tz_MA, this will search for a .mo file with name tz_MA.mo in the language directory inside your theme.

// must be called before load_theme_textdomain()
add_filter( 'locale', 'my_theme_localized' );
function my_theme_localized( $locale )
	if ( isset( $_GET['l'] ) )
		return sanitize_key( $_GET['l'] );

	return $locale;
// Theme translations can be filed in the my_theme/languages/ directory
// WordPress translations can be filed in the wp-content/languages/ directory
load_theme_textdomain( 'my_theme_textdomain', get_template_directory() . '/languages' );


Internationalization and localization (other correct spellings are internationalisation and localisation) are means of adapting computer software to different languages.

  • l10n is an abbreviation for localization.
  • i18n 18 stands for the number of letters between the first i and last n in internationalization.

Change Log

Source File

load_theme_textdomain() is located in wp-includes/l10n.php.

External Resources


Localization: get_locale(), load_textdomain(), load_default_textdomain(), load_plugin_textdomain(), load_theme_textdomain()

See also index of Function Reference and index of Template Tags.