wmnnd

wmnnd

Hey folks,

I’m currently working on adding an address form to Keila. Unfortunately, address forms can be wildly different from country to country. Do they require a postal code? Does the postal code go before or after the locality/city name? On top of that, certain labels for common address fields need to be different between countries (e.g. the relevant administrative region in address is called a state in Mexico but a province in Canada. Postal codes are called Postcode in the UK but ZIP Code in the US.)

Is there an actively maintained Elixir library that offers data on international address formats and these localizations? Here are the libraries I have found so far:

  • countries: Not updated since 2019, doesn’t seem to have any data on address formats
  • countriex: Not updated since 2017, has no documentation
  • ex_countries: Actively maintained, doesn’t have data on address formats.
  • ex_cldr + ex_cldr_territories (friendly ping @kip & @schultzer): Actively maintained, provides all the necessary data to offer dropdowns for the country, including translations of country subdivisions. None of the cldr libraries seem to have any data on address formatting, however. There also doesn’t seem to be data on what the country subdivisions are called (province, state, etc).

Outside the BEAM universe, there is the PHP addressing library which includes most of the data I’m looking for, including address formats (there’s also a Ruby port). The one thing that’s also missing here is country-specific i18n for the various address fields.

What do you all usually do when you need to build an international address form? Did I miss any Elixir resources?

Showing Posts 1 to 6

wmnnd

wmnnd OP

To illustrate what I eventually want to achieve, here are two address forms for Germany and Brazil respectively, built based on the data from the PHP addressing library:


LostKobrakai

LostKobrakai

Sounds like they source their data from cdlr based on their last commit. ex_cldr | Hex exists to pull the database, so we might just lack a companion library exposing the relevant data in a useful way.

wmnnd

wmnnd OP

I don’t think the postal address format is part of CLDR. That seems to come from some sort of Google API.
Edit: This is where the address format data is coming from: Address Data Query

Cochonours

Cochonours

Even within a country, the way fields are presented will vary.

Given name and family name are not enough. In some cases people will want to select a title, and depending on their culture should you use the title with only the family name or the full name? Should the family name be printed before or after the given name? Some people don’t have last names, etc.
For these reasons it is sometimes more practical to have a full name field, though it has its downsides.

wmnnd

wmnnd OP

Good point. The data from Google doesn’t account for titles (and I don’t care for them either, tbh) but they do change the order of family name and given name, e.g. for Vietnam or China, family name comes first. Generally, mononyms seem to be very unommon, so I’m also not particularly concerned about that either.

Schultzer

Schultzer

We definitely could use a library built on top, but you would have to make some decisions on which standard to use. From a cursory search it seams like Oasis is not the only one out there.

The times when I have had to capture this kind of information has always been for identification purposes and not shipping which is an entirely more complex problem. For identification you can usually get away with a minimal setup: country, subdivision, postal code, city, address_2, address_1, name.

Looking forward to see where this is going! And let me know if you have any questions around the CLDR dataset.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews