Drupal 8  8.0.2
LocaleTranslation Class Reference
Inheritance diagram for LocaleTranslation:

Public Member Functions

 __construct (StringStorageInterface $storage, CacheBackendInterface $cache, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager, RequestStack $request_stack)
 
 getStringTranslation ($langcode, $string, $context)
 
 reset ()
 
 destruct ()
 

Protected Member Functions

 canTranslateEnglish ()
 

Protected Attributes

 $storage
 
 $configFactory
 
 $translations = array()
 
 $cache
 
 $lock
 
 $translateEnglish
 
 $languageManager
 
 $requestStack
 

Detailed Description

String translator using the locale module.

Full featured translation system using locale's string storage and database caching.

Constructor & Destructor Documentation

__construct ( StringStorageInterface  $storage,
CacheBackendInterface  $cache,
LockBackendInterface  $lock,
ConfigFactoryInterface  $config_factory,
LanguageManagerInterface  $language_manager,
RequestStack  $request_stack 
)

Constructs a translator using a string storage.

Parameters
\Drupal\locale\StringStorageInterface$storageStorage to use when looking for new translations.
\Drupal\Core\Cache\CacheBackendInterface$cacheThe cache backend.
\Drupal\Core\Lock\LockBackendInterface$lockThe lock backend.
\Drupal\Core\Config\ConfigFactoryInterface$config_factoryThe config factory.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack.

References Drupal\cache(), Drupal\configFactory(), Drupal\languageManager(), Drupal\lock(), and Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

canTranslateEnglish ( )
protected

Gets translate english configuration value.

Returns
bool TRUE if english should be translated, FALSE if not.

References Drupal\configFactory().

Referenced by LocaleTranslation\getStringTranslation().

Here is the call graph for this function:

Here is the caller graph for this function:

destruct ( )

{Performs destruct operations.}

Implements DestructableInterface.

getStringTranslation (   $langcode,
  $string,
  $context 
)

{Retrieves English string to given language.

Parameters
string$langcodeLanguage code to translate to.
string$stringThe source string.
string$contextThe string context.
Returns
string|FALSE Translated string if there is a translation, FALSE if not.
}

Implements TranslatorInterface.

References Drupal\cache(), LocaleTranslation\canTranslateEnglish(), Drupal\configFactory(), LanguageInterface\LANGCODE_SYSTEM, Drupal\languageManager(), Drupal\lock(), and Drupal\requestStack().

Here is the call graph for this function:

reset ( )

{Resets translation cache.Since most translation systems implement some form of caching, this provides a way to delete that cache.}

Implements TranslatorInterface.


The documentation for this class was generated from the following file: