original_string: public static function setTranslator($name, callable $loader, $locale = null)
      {
          $locale = $locale ?: static::getLocale();
  
          $translators = static::translators();
          $loader = $translators->setLoaderFallback($name, $loader);
          $packages = $translators->getPackages();
          $packages->set($name, $locale, $loader);
      }
code: public static function setTranslator($name, callable $loader, $locale = null)
      {
          $locale = $locale ?: static::getLocale();
  
          $translators = static::translators();
          $loader = $translators->setLoaderFallback($name, $loader);
          $packages = $translators->getPackages();
          $packages->set($name, $locale, $loader);
      }
code_tokens: public static function setTranslator ( $ name , callable $ loader , $ locale = null ) { $ locale = $ locale ? : static :: getLocale ( ) ; $ translators = static :: translators ( ) ; $ loader = $ translators -> setLoaderFallback ( $ name , $ loader ) ; $ packages = $ translators -> getPackages ( ) ; $ packages -> set ( $ name , $ locale , $ loader ) ; }
docstring: Sets a translator.
  
  Configures future translators, this is achieved by passing a callable
  as the last argument of this function.
  
  ### Example:
  
  ```
  I18n::setTranslator('default', function () {
  $package = new \Aura\Intl\Package();
  $package->setMessages([
  'Cake' => 'Gâteau'
  ]);
  return $package;
  }, 'fr_FR');
  
  $translator = I18n::getTranslator('default', 'fr_FR');
  echo $translator->translate('Cake');
  ```
  
  You can also use the `Cake\I18n\MessagesFileLoader` class to load a specific
  file from a folder. For example for loading a `my_translations.po` file from
  the `src/Locale/custom` folder, you would do:
  
  ```
  I18n::setTranslator(
  'default',
  new MessagesFileLoader('my_translations', 'custom', 'po'),
  'fr_FR'
  );
  ```
  
  @param string $name The domain of the translation messages.
  @param callable $loader A callback function or callable class responsible for
  constructing a translations package instance.
  @param string|null $locale The locale for the translator.
  @return void
docstring_tokens: Sets a translator .