php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75703 locale is missing address formatting
Submitted: 2017-12-18 20:07 UTC Modified: 2018-05-15 16:04 UTC
From: yves at koekkoek dot fr Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 7.2.0 OS: CentOS
Private report: No CVE-ID: None
 [2017-12-18 20:07 UTC] yves at koekkoek dot fr
Description:
------------
---
From manual page: http://www.php.net/class.locale
---
PECL locale is wonderfull dealing with numbers, currencies and dates.

It might be the place to deal with postal address formatting.

The problem is [lines] and [lines elements] as decribed by the United Nations Universal Postal Union http://www.upu.int/uploads/tx_sbdownloader/descriptionPostcodesGuideToTheHeadingsUsedInThisChapterEn.pdf

For instance :
  - is PostCode before or after City name ?
  - id State(region) name required, possible or forbiden ?
  - is person name before company name ?
  - ...

Working on this subject we found a very simple PHP solution to format any kind of address for all countries => [line index][element name].

We are working now on a simple JSON array of arrays to implements the formats we need.

But could provide a full data set if you think the idea to add such methods to PECL locale has some interest.

Best regards


Expected result:
----------------
=> index names are not the official names here (for readability)!
['fr-FR']
  []['person_name']
  []['organisation']
  []['street-number', 'street-name']
  []['post-code', 'city-name']
  []['country-name']
['en_ZA']
  []['person_name']
  []['organisation']
  []['street-number', 'street-name']
  []['suburb']
  []['city-name']
  []['post-code', 'country-name']


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-15 16:04 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2018-05-15 16:04 UTC] ab@php.net
Thanks for the report. ext/intl is merely a wrapper to ICU, which currently doesn't have the requested functionality. Of course, your suggestion sounds interesting. Another option besides address formatting could be also phone formatting.

I'd suggest you to propose the idea to the ICU project. PHP always relies on the data and routines from ICU. It is used in many projects besides PHP, so having the data is maintained only at one place. Maintaining some data in PHP seems rather inconvenient. If this functionality appears in ICU, it for sure can be wrapped in PHP. I'm closing this ticket therefore, please reopen or create a new ticket, in case there is some update.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC