public function register()
 {
     // Register filter
     $this->app['lari18n'] = $this->app->share(function ($app) {
         return Lari18n::getInstance();
     });
     $this->app['router']->after(function ($request, $response) {
         if (Lari18n::isActivated()) {
             $this->app['lari18n']->modifyResponse($request, $response);
         }
     });
     parent::register();
 }
Example #2
0
 /**
  * Get a translation according to an integer value.
  *
  * @param  string  $key
  * @param  int     $number
  * @param  array   $replace
  * @param  string  $locale
  * @param  bool    $wrap
  *
  * @return string
  */
 public function choice($key, $number, array $replace = array(), $locale = null, $wrap = true)
 {
     if (!Lari18n::isActivated()) {
         return parent::choice($key, $number, $replace, $locale);
     }
     $line = $this->get($key, $replace, $locale = $locale ?: $this->locale, false);
     $replace['count'] = $number;
     $hasTodo = strpos($line, $this->lari18n->todo_translation_key) > -1;
     $chosen = $this->makeReplacements($this->getSelector()->choose($line, $number, $locale), $replace);
     // Reapply the todo_translation_key if needed
     $chosen = $hasTodo ? $this->lari18n->todo_translation_key . $chosen : $chosen;
     if ($wrap == false) {
         return $chosen;
     } else {
         return $this->lari18n->wrap($chosen, $key, $replace, $locale, $number, $wrap);
     }
 }