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

KZ locale instead of RU #438

Closed
are-nic opened this issue Apr 20, 2021 · 9 comments
Closed

KZ locale instead of RU #438

are-nic opened this issue Apr 20, 2021 · 9 comments

Comments

@are-nic
Copy link

are-nic commented Apr 20, 2021

when i select the Russian localization ( PHONENUMBER_DEFAULT_REGION = 'RU' in settings.py), Kazakhstan is displayed in the template

@francoisfreitag
Copy link
Collaborator

Hi,

Can you precise what you see and provide a minimal test case or an example project?
Perhaps double-check the internationalization configuration?

@are-nic
Copy link
Author

are-nic commented Apr 21, 2021

models
forms
kz
settings

@are-nic
Copy link
Author

are-nic commented Apr 21, 2021

if I change the country, then it works correctly. but RU does'n work

@francoisfreitag
Copy link
Collaborator

Good find, it looks like a bug! The following is ordering the prefix by label (Kazakhstan must be before Russia in your alphabet as well).

for prefix, values in _COUNTRY_CODE_TO_REGION_CODE.items():
prefix = "+%d" % prefix
if initial and initial in values:
self.initial = prefix
for country_code in values:
country_name = locale.territories.get(country_code)
if country_name:
choices.append((prefix, "{} {}".format(country_name, prefix)))
super().__init__(choices=sorted(choices, key=lambda item: item[1]))

The value is +7 for both languages. The initial value is set to +7 and the selected option is the first in alphabetical order with value +7.

@are-nic
Copy link
Author

are-nic commented Apr 21, 2021

I thought so, that it's all about the prefix. tell me, can I leave only the prefix without the country name? Some parameter?

@francoisfreitag
Copy link
Collaborator

We would welcome a contribution to fix the original issue.

It think the values should be a mix of region codes and prefixes. Something like f"{prefix}-{region_code}. All options would then have a different value, allowing to select the intended option as the initial value.

@sm-timmy

This comment has been minimized.

@francoisfreitag

This comment has been minimized.

@francoisfreitag
Copy link
Collaborator

I believe this has been fixed with #493.

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

No branches or pull requests

4 participants