-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Fixed variable name used in translation cache #8310
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
Conversation
private function getCatalogueSuffix($locale) | ||
{ | ||
$suffix = str_replace(array('-', '_'), ' ', $locale); | ||
$suffix = mb_convert_case($suffix, MB_CASE_TITLE); |
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.
Please don't introduce a dependency to mbstring (Symfony can be used without mbstring, even if you will face some issues if you use a multibyte encodign in such case)
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.
Ok, I replaced mb_convert_case()
https://github.com/cedric-g/symfony/commit/df9672cb5a85a4bf110348c25036bca87027b4f0 =]
$suffix = str_replace(array('-', '_'), ' ', $locale); | ||
$suffix = ucwords(strtolower($suffix)); | ||
$suffix = str_replace(' ', '', $suffix); | ||
|
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.
What about just replacing -
with _
and be done with it. We don't need to make the variable "pretty", so no need to spend CPU time doing more transformations.
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.
Ok, so I can remove the getCatalogueSuffix()
method and replace it with something like ucfirst(str_replace('-', '_', $locale))
.
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.
yes, looks good to me.
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.
I did the change, does I need to squash my 3 commits into one ?
This PR was submitted for the 2.3 branch but it was merged into the 2.2 branch instead (closes #8310). Discussion ---------- [FrameworkBundle] Fixed variable name used in translation cache This simply fixes the `$catalogueXXX` variable name used in the translation cache files in case the user use locales such as `en-US`, the generated variable's name was `$catalogueEn-Us`, with this fix it will be `$catalogueEnUs`. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7824 | License | MIT | Doc PR | - Commits ------- e50399c [FrameworkBundle] Fixed variable name used in translation cache
I've squashed and merged in 2.2. Thanks. |
This simply fixes the
$catalogueXXX
variable name used in the translation cache files in case the user use locales such asen-US
, the generated variable's name was$catalogueEn-Us
, with this fix it will be$catalogueEnUs
.