Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 3 commits into from
Closed

[FrameworkBundle] Fixed variable name used in translation cache #8310

wants to merge 3 commits into from

Conversation

cedric-g
Copy link

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 -

private function getCatalogueSuffix($locale)
{
$suffix = str_replace(array('-', '_'), ' ', $locale);
$suffix = mb_convert_case($suffix, MB_CASE_TITLE);
Copy link
Member

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$suffix = str_replace(array('-', '_'), ' ', $locale);
$suffix = ucwords(strtolower($suffix));
$suffix = str_replace(' ', '', $suffix);

Copy link
Member

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.

Copy link
Author

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)).

Copy link
Member

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.

Copy link
Author

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 ?

fabpot added a commit that referenced this pull request Jun 24, 2013
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
@fabpot
Copy link
Member

fabpot commented Jun 24, 2013

I've squashed and merged in 2.2. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants