get_translations_for_domain() WordPress Function

The get_translations_for_domain() function is used to get the translations for a given domain. This is useful for plugins and themes that need to load translations for their own text domains.

get_translations_for_domain( string $domain ) #

Return the Translations instance for a text domain.


Description

If there isn’t one, returns empty Translations instance.


Top ↑

Parameters

$domain

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


Top ↑

Return

(Translations|NOOP_Translations) A Translations instance.


Top ↑

Source

File: wp-includes/l10n.php

function get_translations_for_domain( $domain ) {
	global $l10n;
	if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
		return $l10n[ $domain ];
	}

	static $noop_translations = null;
	if ( null === $noop_translations ) {
		$noop_translations = new NOOP_Translations;
	}

	return $noop_translations;
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.