class PassthroughTranslator in Backup and Migrate 8.4
This translator service simply passes through the us-english strings with the replacement tokens substituted in.
Class PassthroughTranslator.
@package BackupMigrate\Core\Service
Hierarchy
- class \BackupMigrate\Core\Translation\PassthroughTranslator implements TranslatorInterface
Expanded class hierarchy of PassthroughTranslator
File
- lib/
backup_migrate_core/ src/ Translation/ PassthroughTranslator.php, line 15
Namespace
BackupMigrate\Core\TranslationView source
class PassthroughTranslator implements TranslatorInterface {
/**
* @param string $string
* The string to be translated.
* @param $replacements
* Any untranslatable variables to be replaced into the string.
* @param $context
* Extra context to help translators distinguish ambiguous strings.
*
* @return mixed
*/
public function translate($string, $replacements = [], $context = []) {
// Provide Drupal-like escaping of replacement values.
foreach ($replacements as $key => $value) {
switch (substr($key, 0, 1)) {
case '@':
case '%':
$replacements[$key] = strip_tags($value);
break;
}
}
return strtr($string, $replacements);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PassthroughTranslator:: |
public | function |
Overrides TranslatorInterface:: |