You are here

public function PassthroughTranslator::translate in Backup and Migrate 8.4

Parameters

string $string: The string to be translated.

$replacements: Any untranslatable variables to be replaced into the string.

$context: Extra context to help translators distinguish ambiguous strings.

Return value

mixed

Overrides TranslatorInterface::translate

File

lib/backup_migrate_core/src/Translation/PassthroughTranslator.php, line 27

Class

PassthroughTranslator
This translator service simply passes through the us-english strings with the replacement tokens substituted in.

Namespace

BackupMigrate\Core\Translation

Code

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);
}