{"id":19601246,"url":"https://github.com/tonglil/localize","last_synced_at":"2025-10-27T17:05:56.496Z","repository":{"id":21818080,"uuid":"25140897","full_name":"tonglil/Localize","owner":"tonglil","description":"A library to localize location-based attributes based on regular expressions.","archived":false,"fork":false,"pushed_at":"2014-12-23T19:59:53.000Z","size":896,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T07:49:45.147Z","etag":null,"topics":["formatter","localization","php"],"latest_commit_sha":null,"homepage":"http://tonglil.github.io/Localize","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonglil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-13T03:09:01.000Z","updated_at":"2014-12-23T19:59:53.000Z","dependencies_parsed_at":"2022-08-19T23:01:06.291Z","dependency_job_id":null,"html_url":"https://github.com/tonglil/Localize","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonglil%2FLocalize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonglil%2FLocalize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonglil%2FLocalize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonglil%2FLocalize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonglil","download_url":"https://codeload.github.com/tonglil/Localize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240879576,"owners_count":19872391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatter","localization","php"],"created_at":"2024-11-11T09:17:42.587Z","updated_at":"2025-10-27T17:05:51.450Z","avatar_url":"https://github.com/tonglil.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Localize\n\n[![Build Status](https://img.shields.io/travis/tonglil/Localize.svg)](https://travis-ci.org/tonglil/Localize)\n[![Coverage Status](https://img.shields.io/coveralls/tonglil/Localize.svg)](https://coveralls.io/r/tonglil/Localize)\n[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/tonglil/Localize.svg)](https://scrutinizer-ci.com/g/tonglil/Localize/?branch=master)\n\n[![Total Downloads](https://poser.pugx.org/tonglil/localize/downloads.svg)](https://packagist.org/packages/tonglil/Localize)\n[![Latest Stable Version](https://poser.pugx.org/tonglil/localize/v/stable.svg)](https://packagist.org/packages/tonglil/Localize)\n[![Latest Unstable Version](https://poser.pugx.org/tonglil/localize/v/unstable.svg)](https://packagist.org/packages/tonglil/Localize)\n[![License](https://poser.pugx.org/tonglil/localize/license.svg)](https://packagist.org/packages/tonglil/Localize)\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/3ab73b7b-5159-4bfe-8c85-2a15d03f9579/big.png)](https://insight.sensiolabs.com/projects/3ab73b7b-5159-4bfe-8c85-2a15d03f9579)\n\nA library to localize location-based attributes and coerce values into desired formats based on regular expressions.\n\nNote: *this is not a translation or i18n library.*\n\nMore locales to come - please feel free to submit a PR if you would like to help fill the missing holes!\n\n## Contents\n\n- [Installation](#install)\n- [Locales](#locales)\n- [Formats](#formats)\n- [Examples](#examples)\n- [API documentation](http://tonglil.github.io/Localize/).\n\n## Install\n\nThe recommended way to install is through [Composer](http://getcomposer.org).\n\nUpdate your project's composer.json file to include Localize:\n\n```json\n{\n    \"require\": {\n        \"tonglil/localize\": \"1.*\"\n    }\n}\n```\n\nThen update the project dependencies to include this library:\n\n```bash\ncomposer update tonglil/localize\n```\n\nAfter installing, you need to require Composer's autoloader:\n\n```php\nrequire 'vendor/autoload.php';\n```\n\n## Locales\n\nCountry codes are based on [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1).\nPhone numbers can be formatted to [E.164 formatting](http://en.wikipedia.org/wiki/E.164)\n\nLocales currently supported:\n- CA\n\nPlanned locales:\n- US\n- FR\n- GB\n- AU\n- CN\n\nLocales are stored in [src/locales](src/locales) directory.\n\n## Formats\n\nThe default formats currently supported:\n\n- Region (province/state)\n- Post code (postal/zip code)\n- Country name\n- Phone number (regional \"de-facto\" formatting or E.164 formatting)\n\n## Examples\n\n```php\nuse Localize\\Localize;\n\n// Create a new localize instance.\n$localize = new Localize();\n// Set the locale using a two digit ISO country code.\n$localize-\u003esetLocale('CA');\n\n$address = [\n    'address'       =\u003e '525 Seymour Street',\n    'city'          =\u003e 'Vancouver',\n    'region'        =\u003e $localize-\u003eregion('british columbia', true),\n    'postal_code'   =\u003e $localize-\u003epostalCode('v6b3h7'),\n    'country'       =\u003e $localize-\u003ecountry('CANADA', false),\n    'phone'         =\u003e $localize-\u003ephone('5555555555'),\n];\n\necho $address['region'];        // BC\necho $address['postal_code'];   // V6B 3H7\necho $address['country'];       // Canada\necho $address['phone'];         // 555-555-5555\n\n// Region and country both accept a second parameter that formats the value to\n// its short version when true, otherwise uses the long version by default.\necho $localize-\u003eregion('ontario', true);    // ON\necho $localize-\u003eregion('ontario', false);   // Ontario\n\n// Postal code and phone number will attempt to massage a limit amount of\n// formatting into the standard output.\necho $localize-\u003ephone('555 555-5555');                  // 555-555-5555 regional \"de-facto\" formatting\necho $localize-\u003ephoneE164('+1 555 555-5555');           // 011-1-555-555-5555 full E.164 formatting\necho $localize-\u003ephoneE164('+1 555 555-5555', false);    // +1-555-555-5555 common E.164 formatting\necho $localize-\u003epostalCode('V6b 3h7');                  // V6B 3H7\n\n// Basic validation is performed; if a match is not found and can not be\n// massaged to a format, null is returned.\nvar_dump($localize-\u003ephone('abc-def-gehi')); // null\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonglil%2Flocalize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonglil%2Flocalize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonglil%2Flocalize/lists"}