leodido / i18n.phonenumbers.js

Parse, format, and validate international phone numbers through libphonenumber
18 stars 14 forks source link

Build localized versions of library #4

Closed leodido closed 9 years ago

leodido commented 9 years ago

E.g.,

Goals:

  1. Gulp task that takes country ISO as input and build the library subset
  2. Script that publish all this libraries separately on bower (users may want to download only what interests them closely)
leodido commented 9 years ago

Metadata are generated running the command.

java -jar \
bower_components/libphonenumber/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar \
BuildMetadataJsonFromXml

But this command class does not have an option to filter metadata by code.

leodido commented 9 years ago

Alternatively, we can filter metadata directly in JavaScript.

/**
 * @type {!Object.<number, Array.<string>>}
 */
i18n.phonenumbers.metadata.countryCodeToRegionCodeMap = {
// ...
};
/**
 * A mapping from a region code to the PhoneMetadata for that region.
 * @type {!Object.<string, Array>}
 */
i18n.phonenumbers.metadata.countryToMetadata = {
// ...
};