On this page
get_translations_for_domain( string $domain ): Translations|NOOP_Translations
Returns the Translations instance for a text domain.
Description
If there isn’t one, returns empty Translations instance.
Parameters
$domainstring Required-
Text domain. Unique identifier for retrieving translated strings.
Return
Translations|NOOP_Translations A Translations instance.
Source
File: wp-includes/l10n.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| _load_textdomain_just_in_time() wp-includes/l10n.php | Loads plugin and theme text domains just-in-time. |
Used By
| Used By | Description |
|---|---|
| WP_Locale_Switcher::load_translations() wp-includes/class-wp-locale-switcher.php | Load translations for a given locale. |
| translate() wp-includes/l10n.php | Retrieves the translation of $text. |
| translate_with_gettext_context() wp-includes/l10n.php | Retrieves the translation of $text in the context defined in $context. |
| _n() wp-includes/l10n.php | Translates and retrieves the singular or plural form based on the supplied number. |
| _nx() wp-includes/l10n.php | Translates and retrieves the singular or plural form based on the supplied number, with gettext context. |
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_translations_for_domain