Locates translation for a given string and text domain.
Parameters
$singular
stringrequired- Singular translation.
$textdomain
stringoptional- Text domain. Default
'default'
.Default:
'default'
$locale
stringoptional- Locale. Default current locale.
Default:
null
Source
protected function locate_translation( string $singular, string $textdomain = 'default', ?string $locale = null ) {
if ( array() === $this->loaded_translations ) {
return false;
}
// Find the translation in all loaded files for this text domain.
foreach ( $this->get_files( $textdomain, $locale ) as $moe ) {
$translation = $moe->translate( $singular );
if ( false !== $translation ) {
return array(
'entries' => explode( "\0", $translation ),
'source' => $moe,
);
}
if ( null !== $moe->error() ) {
// Unload this file, something is wrong.
$this->unload_file( $moe, $textdomain, $locale );
}
}
// Nothing could be found.
return false;
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.