-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Translator] fix fallback to Locale::getDefault()
- Loading branch information
1 parent
5f70730
commit c1cca3e
Showing
2 changed files
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c1cca3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke usage of Carbon on systems that don't have the Locale class present for some reason, still investigating. @briannesbitt @nicolas-grekas
c1cca3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically getLocale() returning 'en' instead of null on environments without php-intl installed and enabled (thus the Locale class is not present). An environment that did have it installed and enabled still worked fine, but was reporting the default locale as 'en_US_POSIX'
c1cca3e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue stems from these lines in Carbon here: https://github.com/briannesbitt/Carbon/blob/dad1ee0c17/src/Carbon/Translator.php#L329-L331 which was added in briannesbitt/Carbon@c4806c9#diff-e10ba6a836bd0ec56e856e73ba2145575d9561b3ac40f734b6dc4bca918440d2R254-R256 to prevent unnecessary reloading of the current locale. However, this commit breaks that logic because on the initial load of the Translator instead of
$this->getLocale()
returning null (and thus failing that check) it now returns'en'
which matches the default locale being initialized by Carbon on some environments causing the first load of the localization to not occur correctly.