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

Localization: Country names #5070

Closed
vaclavstepan opened this issue Sep 1, 2021 · 7 comments · Fixed by #5076
Closed

Localization: Country names #5070

vaclavstepan opened this issue Sep 1, 2021 · 7 comments · Fixed by #5076
Labels
Projects
Milestone

Comments

@vaclavstepan
Copy link
Contributor

Describe the bug
When registration includes list of contry names, it uses English versions of their names.
For an event held in a different language this is unpleasant.

To Reproduce
Steps to reproduce the behavior:

  1. Create a conference with a participant registration
  2. In participant registration form, see the values in the Country drop down menu

Expected behavior
Country names should respect the event language.

@ThiefMaster
Copy link
Member

Hm, tricky one. We get those country names from pycountry but AFAIK it only contains the English names.

The only solution I see there is generating a file with all the country names wrapped as translatable strings so they can get extracted for translation...

@vaclavstepan
Copy link
Contributor Author

vaclavstepan commented Sep 1, 2021 via email

@ThiefMaster
Copy link
Member

Oh nice, hadn't noticed that. That should make things much easier for sure.

@pferreir
Copy link
Member

pferreir commented Sep 6, 2021

I don't think pycountry is even needed. You have all that information already in babel. e.g.:

In [40]: from babel import Locale

In [41]: cs_CZ = Locale('cs', 'CZ')

In [42]: cs_CZ.languages['gsw']
Out[42]: 'němčina (Švýcarsko)'

In [43]: cs_CZ.languages['pt']
Out[43]: 'portugalština'

@ThiefMaster
Copy link
Member

For the country name you probably want get_current_locale().territories.get(x) with a fallback to the untranslated name (e.g. for custom countries defined via CUSTOM_COUNTRIES or countries that no longer exist (e.g. SU = Soviet Union))

@tomasr8
Copy link
Member

tomasr8 commented Sep 6, 2021

The babel Locale.territories also include things like continents and regions. The continents can be easily flitered out since they don't use the alpha-2 codes, but then there are things like EU - European Union and EZ - Eurozone (seems weird, didn't find a mention of this in iso3166). Should we keep it in the list?

@ThiefMaster
Copy link
Member

You'd still get the list from pycountry.. babel would just be used to look up a translated name.. Something like this:

{code: locale.territories.get(code, name) for code, name in get_countries().items()}

@ThiefMaster ThiefMaster added this to the v3 milestone Sep 7, 2021
@ThiefMaster ThiefMaster added this to To do in Release 3.0 via automation Sep 7, 2021
@ThiefMaster ThiefMaster moved this from To do to Done in Release 3.0 Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Release 3.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants