public LocaleConfigManager::getStringTranslation($name, $langcode, $source, $context)
Get the translation object for the given source/context and language.
Parameters
string $name: Name of the configuration location.
string $langcode: Language code to translate to.
string $source: The source string, should be English.
string $context: The string context.
Return value
\Drupal\locale\TranslationString|false The translation object if the string was not empty or FALSE otherwise.
File
- core/modules/locale/src/LocaleConfigManager.php, line 440
Class
- LocaleConfigManager
- Manages configuration supported in part by interface translation.
Namespace
Drupal\locale
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public function getStringTranslation( $name , $langcode , $source , $context ) { if ( $source ) { $this ->translateString( $name , $langcode , $source , $context ); if ( $string = $this ->translations[ $name ][ $langcode ][ $context ][ $source ]) { if (! $string ->isTranslation()) { $conditions = array ( 'lid' => $string ->lid, 'language' => $langcode ); $translation = $this ->localeStorage->createTranslation( $conditions ); $this ->translations[ $name ][ $langcode ][ $context ][ $source ] = $translation ; return $translation ; } else { return $string ; } } } return FALSE; } |
Please login to continue.