public function test_jalali_after_or_before_replacer_is_applied_with_date()
 {
     $this->translator->setLocale('fa');
     $faNow = '۱۳۹۴/۹/۱۴';
     $validator = $this->factory->make(['birth_date' => 'garbage'], ['birth_date' => "required|jalali_after:{$faNow}|jalali_before:{$faNow}"]);
     $this->assertTrue($validator->fails());
     $this->assertEquals(['birth_date' => ["تاریخ تولد وارد شده باید یک تاریخ شمسی معتبر بعد از {$faNow} باشد.", "تاریخ تولد وارد شده باید یک تاریخ شمسی معتبر قبل از {$faNow} باشد."]], $validator->messages()->toArray());
 }
Example #2
0
 /**
  *    Return the HTML representation of the email to be sent.
  *
  *    @return string
  */
 public function getBody()
 {
     // Set the email's locale:
     $appLocale = $this->translator->getLocale();
     if ($this->locale && $this->locale != $appLocale) {
         $this->translator->setLocale($this->locale);
     }
     // Generate HTML:
     $html = $this->viewFactory->make($this->view, $this->data)->render();
     $css = $this->filesystem->get(base_path($this->cssFile));
     $inliner = new CssToInlineStyles($html, $css);
     $body = $inliner->convert();
     // Return App locale to former value:
     if ($this->locale && $this->locale != $appLocale) {
         $this->translator->setLocale($appLocale);
     }
     return $body;
 }
Example #3
0
 /**
  * Set the default locale.
  *
  * @param string $locale
  * @return void 
  * @static 
  */
 public static function setLocale($locale)
 {
     \Illuminate\Translation\Translator::setLocale($locale);
 }
Example #4
0
 /**
  * test changing locale should fetch from other language file
  */
 public function testOtherLocale()
 {
     $this->trans->setLocale('nl');
     $this->assertEquals('postcode', $this->trans->get('inputs.postal-code'));
 }
Example #5
0
 /**
  * {@inheritdoc}
  *
  * @param string $locale The locale
  *
  * @throws \InvalidArgumentException If the locale contains invalid characters
  *
  * @api
  */
 public function setLocale($locale)
 {
     return $this->lang->setLocale($locale);
 }
 /**
  * Get the default locale being used.
  *
  * @return string
  */
 public function getLocale()
 {
     if ($this->useCookies) {
         $locale = \Cookie::get($this->cookiePrefix . 'lang_locale', parent::getLocale());
         if ($locale != parent::getLocale()) {
             parent::setLocale($locale);
         }
     }
     return parent::getLocale();
 }