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

Kazakhstan address format #203

Closed
mattarmitage opened this issue Nov 23, 2023 · 8 comments
Closed

Kazakhstan address format #203

mattarmitage opened this issue Nov 23, 2023 · 8 comments

Comments

@mattarmitage
Copy link

I am using the Address module in Drupal 9 which relies on the formatting in this library. When selecting Kazakhstan as country the format is changed but I do not think it is correct as it puts the postal code first.
I've done some research and I don't see why the format is set in this order. I see some difference in the order if the address is in cyrillic format, but not identical to what is being enforced, and this shouldn't be a default anyway.
Attached an example of the order it appears in Drupal 9 for Kazakhstan.
Screenshot_20231123_170208_Chrome~2.jpg

@bojanz
Copy link
Contributor

bojanz commented Nov 23, 2023

Indeed, the postal code comes first in the address format:

'KZ' => [
    'format' => "%postalCode\n%administrativeArea\n%locality\n%addressLine1\n%addressLine2\n%addressLine3\n%organization\n%familyName %givenName %additionalName",
    'postal_code_pattern' => '\d{6}',
],

This is highly unusual, most address formats aren't like that. Looks like we imported it like that from Google's address data service.

We can change it to something more sensible, but we need an authoritative source, such as a kazpost link.

If kazpost has no resource that we can reference, we can fall back to UPU's rules, which also list the postalCode as standing next to the locality, after the address lines.

Looks like we also need to update the postal code pattern, as UPU says it's 7 alphanumeric characters, not 6 digits.

@bojanz
Copy link
Contributor

bojanz commented Nov 23, 2023

@mattarmitage How does this sound:

        'KZ' => [
            'format' => "%familyName %givenName %additionalName\n%organization\n%addressLine1\n%addressLine2\n%addressLine3\n%postalCode, %locality\n%administrativeArea",
            'required_fields' => [
                'addressLine1', 'locality', 'postalCode',
            ],
            'administrative_area_type' => 'region',
            'postal_code_pattern' => '[A-Z0-9]{7}',
        ],

It changes the used layout, makes the postalCode required, and uses a format of 7 alphanumeric characters. It changes the administrative area label from "state" to "region".

We also need to add a list of regions. I was thinking of using the English names from https://en.wikipedia.org/wiki/Regions_of_Kazakhstan as the default + the latin Kazakh names (e.g. "Abai oblysy") when the language code is kk.

The alternative would be to use the Kazakh names as the default + the Russian names when the language code is "ru", but the English names feel easier to understand to foreigners.

@mattarmitage
Copy link
Author

mattarmitage commented Nov 23, 2023 via email

@bojanz
Copy link
Contributor

bojanz commented Nov 23, 2023

Okay, let's go with \d{5}|[A-Z0-9]{7} as the regexp then, to support both.

I've also edited my comment above to ask about the regions, please let me know.

@mattarmitage
Copy link
Author

The regions are beyond my knowledge! They would be good additions though.

@mattarmitage
Copy link
Author

I spoke with some Kazakhs and they said the weird format was a soviet Russian thing and it has been standardised now to match global standards but basically everyone uses all kinds of formats there.
But officially it is the same as western format.

@bojanz bojanz closed this as completed in 32ba377 Nov 24, 2023
@bojanz
Copy link
Contributor

bojanz commented Nov 24, 2023

Great, pushed a commit that reworks the address format.

I am still waiting on feedback regarding the region names, once I have that I will commit the regions too and report back here. We can then tag a new release.

@bojanz
Copy link
Contributor

bojanz commented Nov 24, 2023

Opened #204 to track adding the regions.

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

No branches or pull requests

2 participants