本文整理汇总了PHP中Illuminate\Translation\Translator::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::setLocale方法的具体用法?PHP Translator::setLocale怎么用?PHP Translator::setLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Translation\Translator
的用法示例。
在下文中一共展示了Translator::setLocale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_jalali_after_or_before_replacer_is_applied_with_date
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());
}
示例2: getBody
/**
* 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;
}
示例3: setLocale
/**
* Set the default locale.
*
* @param string $locale
* @return void
* @static
*/
public static function setLocale($locale)
{
\Illuminate\Translation\Translator::setLocale($locale);
}
示例4: testOtherLocale
/**
* 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'));
}
示例5: setLocale
/**
* {@inheritdoc}
*
* @param string $locale The locale
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*
* @api
*/
public function setLocale($locale)
{
return $this->lang->setLocale($locale);
}
示例6: getLocale
/**
* 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();
}