You are here

protected static function Carbon::translator in Persian Date for Drupal 8 8.4

Initialize the translator instance if necessary.

Return value

\Symfony\Component\Translation\TranslatorInterface

2 calls to Carbon::translator()
Carbon::getTranslator in src/Library/Carbon/Carbon.php
Get the translator instance in use
Carbon::setLocale in src/Library/Carbon/Carbon.php
Set the current translator locale and indicate if the source locale file exists

File

src/Library/Carbon/Carbon.php, line 1102

Class

Carbon
A simple API extension for DateTime

Namespace

Drupal\persian_date\Library\Carbon

Code

protected static function translator() {
  if (static::$translator === null) {
    $translator = new Translator('en');
    $translator
      ->addLoader('array', new ArrayLoader());
    static::$translator = $translator;
    static::setLocale('en');
  }
  return static::$translator;
}