is_textdomain_loaded( string $domain )

Whether there are translations for the text domain.

Parameters Parameters


(string) (Required) Text domain. Unique identifier for retrieving translated strings.

Top ↑

Return Return

(bool) Whether there are translations.

Top ↑

Source Source

File: wp-includes/l10n.php

function is_textdomain_loaded( $domain ) {
	global $l10n;
	return isset( $l10n[ $domain ] );

Top ↑

Changelog Changelog

Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Aurovrata Venet

    There are situations where one requires a plugin translation locale to be loaded which is different from the current user locale.

    For example, in multilingual websites, creating a translation of a post/widget requires some translations to be loaded for a given plugin text domain. The user locale (dashboard locale) is loaded by default, so it is important to unload that if it has been loaded already and seek the translation file to load for the text domain for the requested locale,

    if ( is_textdomain_loaded( $plugin ) ) {
    	unload_textdomain( $plugin );
    $mofile = sprintf( '', $plugin, $locale );
    //check the installation language path first.
    $domain_path = path_join( WP_LANG_DIR, 'plugins' );
    load_textdomain( $plugin, path_join( $domain_path, $mofile ) );
    if ( ! $loaded ) { //else, check the plugin language folder.
    	$domain_path = path_join( WP_PLUGIN_DIR, "{$plugin}/languages" );
    	$loaded = load_textdomain( $plugin, path_join( $domain_path, $mofile ) );

You must log in before being able to contribute a note or feedback.