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

Translate country #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

MintL
Copy link
Contributor

@MintL MintL commented Apr 22, 2017

Adds the possibility to request a localised version of countries.
Changed in match mail, profile, and some minor places but
there are probably more places to change. However, if no locale
is selected it will still default to swedish so there should be
no breaking changes.

MintL added 2 commits April 22, 2017 15:10
Adds the possibility to request a localised version of
countries.
Changed in match mail, profile, and some minor places but
there are probably more places to change. However, if no locale
is selected it will still default to swedish so there should be
no breaking changes.
@jongotlin
Copy link
Member

Thanks for your submission! However, I would prefer to use Symfony's own translation package.

I suggest you to put all countries in a xliff file located at app/Resources/translations/countries.sv.xliff.

<trans-unit id="SE">
    <source>SE</source>
    <target>Sverige</target>
</trans-unit>

In a view file you can then translate the country with {{ user.from|trans({}, 'countries') }}.

The method getCountryName should probably not be used at all.

When using the translator in a form type you have to inject the service translator into the class. See how it is done in MatchFilterType.

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.

2 participants