Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*fix - User Deprecated - Passing "null" as the $locale argument to Sy… #174

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
17 changes: 8 additions & 9 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function __construct(
$this->translationsLoader = $loader;

parent::__construct('', $formatter);
$this->setLocale(NULL);
}

/**
Expand Down Expand Up @@ -195,7 +194,7 @@ public function trans($message, array $parameters = [], $domain = NULL, $locale
}

if ($domain === NULL) {
list($domain, $id) = $this->extractMessageDomain($message);
[$domain, $id] = $this->extractMessageDomain($message);

} else {
$id = $message;
Expand Down Expand Up @@ -224,7 +223,7 @@ public function transChoice($message, $number, array $parameters = [], $domain =
}

if ($domain === NULL) {
list($domain, $id) = $this->extractMessageDomain($message);
[$domain, $id] = $this->extractMessageDomain($message);

} else {
$id = $message;
Expand All @@ -242,10 +241,10 @@ public function transChoice($message, $number, array $parameters = [], $domain =

if ($result === "\x01") {
$this->logMissingTranslation($message, $domain, $locale);
if ($locale === NULL) {
if ($locale === null) {
$locale = $this->getLocale();
}
if ($locale === NULL) {
if ($locale === '') {
$result = strtr($message, $parameters);

} else {
Expand Down Expand Up @@ -340,17 +339,17 @@ public function getAvailableLocales()
*/
public function setLocale($locale)
{
parent::setLocale($locale);
parent::setLocale((string)$locale);
}

/**
* Returns the current locale.
*
* @return string|NULL The locale
* @return string The locale
*/
public function getLocale()
{
if (parent::getLocale() === NULL) {
if (parent::getLocale() === '') {
$this->setLocale($this->localeResolver->resolve($this));
}

Expand Down Expand Up @@ -437,7 +436,7 @@ protected function assertValidLocale($locale)
private function extractMessageDomain($message)
{
if (strpos($message, '.') !== FALSE && strpos($message, ' ') === FALSE) {
list($domain, $message) = explode('.', $message, 2);
[$domain, $message] = explode('.', $message, 2);

} else {
$domain = 'messages';
Expand Down