All Projects → OpenCageData → Address Formatting

OpenCageData / Address Formatting

Licence: mit
templates to format geographic addresses

Programming Languages

perl
6916 projects

Projects that are alternatives of or similar to Address Formatting

address-formatter
Universal international address formatter in Javascript
Stars: ✭ 65 (-74.31%)
Mutual labels:  i18n, formatting
Fluent.js
JavaScript implementation of Project Fluent
Stars: ✭ 622 (+145.85%)
Mutual labels:  i18n, formatting
language-subtag-registry
BCP 47/IANA language subtag data in JSON format.
Stars: ✭ 53 (-79.05%)
Mutual labels:  i18n
labels
Bolt Labels extension - Translatable labels for Bolt
Stars: ✭ 18 (-92.89%)
Mutual labels:  i18n
Chatty
Bukkit-compatible chat plugin with multiple chat-modes.
Stars: ✭ 30 (-88.14%)
Mutual labels:  formatting
gutenberg-i18n-block
Gutenberg block to demo internationalization functionality.
Stars: ✭ 35 (-86.17%)
Mutual labels:  i18n
polib
Pure python library to manipulate, create, modify gettext files (pot, po and mo files).
Stars: ✭ 34 (-86.56%)
Mutual labels:  i18n
python-fluent
Python implementation of Project Fluent
Stars: ✭ 142 (-43.87%)
Mutual labels:  i18n
wp-l10n-validator
Gettext localization validator for WordPress
Stars: ✭ 17 (-93.28%)
Mutual labels:  i18n
camunda-modeler-i18n-plugin
This plugin allows you to translate the UI of the Camunda Modeler. It contains ready-to-use translations for German, English, and Portuguese and can be easily extended or customized.
Stars: ✭ 14 (-94.47%)
Mutual labels:  i18n
format.nvim
Neovim lua plugin to format the current buffer with external executables
Stars: ✭ 189 (-25.3%)
Mutual labels:  formatting
jsonapi-swagger
Create a JSONAPI Swagger.
Stars: ✭ 49 (-80.63%)
Mutual labels:  i18n
sublime-php-grammar
An smart macro PHP plugin for Sublime Text.
Stars: ✭ 30 (-88.14%)
Mutual labels:  formatting
vue-i18n-manager
Internationalization plugin for Vue
Stars: ✭ 18 (-92.89%)
Mutual labels:  i18n
auto-translate-converter
a cli work for part of i18n project chain
Stars: ✭ 19 (-92.49%)
Mutual labels:  i18n
vim-localorie
A Vim plugin for easy look-up of translations for Rails i18n YAML keys.
Stars: ✭ 27 (-89.33%)
Mutual labels:  i18n
language-tags
A Swiss Army knife for language tags.
Stars: ✭ 46 (-81.82%)
Mutual labels:  i18n
kirai
String formatting library for Java, Android, Web and Unix Terminal
Stars: ✭ 69 (-72.73%)
Mutual labels:  formatting
i18n
Package i18n is for app Internationalization and Localization.
Stars: ✭ 79 (-68.77%)
Mutual labels:  i18n
Flutter i18n
This plugin create a binding between your translations from .arb files and your Flutter app.
Stars: ✭ 255 (+0.79%)
Mutual labels:  i18n

address formatting

Overview

This project contains templates and test cases for address formats used in territories around the world. The templates can then be processed in any programming language (see below for list of processors).

Build Status

Build Status Twitter Follow

An example:

Given a set of address parts like

 house_number:  17
 road:          Rue du Médecin-Colonel Calbairac
 neighbourhood: Lafourguette
 suburb:        Toulouse Ouest
 postcode:      31000
 city:          Toulouse
 county:        Toulouse
 state:         Midi-Pyrénées
 country:       France
 country_code:  FR

we want to write logic to compile an address in the format consumers expect

17 Rue du Médecin-Colonel Calbairac
31000 Toulouse
France

Why would you want to do this?

The intended use case is database or geocoding systems (forward, reverse, autocomplete) where we know both the country of the address and the language of the user/reader. The address is displayed to a consumer (for example in an app) and not used to print on an envelope for actual postal delivery. We use it to format output from the OpenCage Geocoder.

Which addresses are we talking about?

We have to deal with

  • incomplete data
  • anything with a name (peaks, bridges, bus stops)

Unlike physical post (office) mail we don't have to deal with

  • apartment/flat number, floor numbers
  • PO boxes
  • translating the language of the (destination) address. Whatever language is input is output.

Processing logic

Our goal with this repository is a series of (programming) language independent templates. Those templates can then be processed by whatever software you like.

There are open-source implementations in

We would love more language implementations. The more people who use the templates, the more likely bugs will be reported. If you write a processor, please submit a pull request adding it to the list. Thanks.

International coverage

As of Sun 17 Feb 2019 coverage is:

We are aware of 248 territories
We have tests for 248 (100%) territories
We have rules for 248 (100%) territories
0 (0%) territories have neither rules nor tests

This output is generated by bin/coverage.pl

We need more language specific abbreviations. Please see conf/abbreviations. Pull requests gladly received.

A detailed breakdown of test and configuration coverage can be found by running bin/coverage.pl -d. A list of all known territories is in conf/country_codes.yaml

Please note: the list is simple all officially assigned ISO 3166-1 alpha-2 codes, and is not a political statement on whether or not these territories are or are not or should or should not be political states.

File format

The files are in YAML format. The templates are written in Mustache. Both formats are human readable, strict, solve escaping and support comments. YAML allows references (called "ankers") to avoid copy&paste, Mustache allows sub-templates (called "partials").

How to add your country/territory

  1. edit the .yaml testcase for the country/territory in testcases/countries. The file names correspond to the appropriate ISO 3166-1 alpha-2 code - see conf/country_codes.yaml
  • a good way to get sample data is:
    • find an addressed location (house, business, etc) in your target territory in OpenStreetMap
    • get the coordinates (lat, long) of the location
    • put the coordinates into the OpenCage Geocoder demo page
    • look at the resulting JSON in the Raw Response tab
  1. edit conf/countries/worldwide.yaml
  • Possibly your country/territory uses an existing generic format as defined at the top of the file. If so, great, just map you country_code to the generic template. You may still want to add clean up code (see the entry for DE as an example).
  • If not you need to define a new generic rule set
    • possibly you will need to define new state/region mappings in conf/state_codes.yaml
  1. to test you will now need to process the .yaml test via a processer (see above) and ensure the input leads to the desired output.

If in doubt, please get in touch by submitting an issue.

Formatting rules

Currently we support the following formatting rules:

  • replace: regex that operates on the input values, useful for removing bureaucratic cruft like "London Borough of ". Note if you define the regex starting with format X=, for example city= it should operate only on values with that key
  • postformat_replace: regex that operates on the final output
  • add_component: with a value of the form component=XXXX
  • change_country: change the country value of the input, useful for dependent territories. Can include a substitution like $state so that that component value is then inserted into the new country value. See testcases/countries/sh.yaml for an example.
  • use_country: use the formating configuration of another country, useful for dependent territories to avoid duplicating configuration

The future

More tests! For every rule about addresses there are exceptions and edge cases to consider. More test cases are always needed.

Planned features:

  • basic error checking, for example ignore things which obviously can not be postcodes
  • define rules for postcode format specifically

We welcome your pull requests. Together we can address the world!

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

Further reading on the challenge of address

Here's our blog post anouncing this project and the motivations behind it.

You may enjoy Michael Tandy's Falsehoods Programmers Believe about Addresses.

If it's actual address data you're after, check out OpenStreetMap and OpenAddresses.

If you want to turn longitude, latitude into well formatted addresses or placenames, well that's what a geocoder does. Check out ours: OpenCage Geocoder.

If all this convinces you that address are evil, please check out what3words which allows you to dispense with them entirely.

Who is OpenCage GmbH?

We run the OpenCage Geocoder. Learn more about us.

We also run Geomob, a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy the Geomob podcast.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].