Google's JavaScript library for parsing, formatting, and validating international phone numbers.
git clone https://github.com/googlei18n/libphonenumber/
git clone https://github.com/google/closure-library/
git clone https://github.com/google/closure-compiler.git
svn checkout http://closure-linter.googlecode.com/svn/trunk/ ~/src/closure-linter
svn checkout http://python-gflags.googlecode.com/svn/trunk/ ~/src/python-gflags
If you don't checkout the dependencies next to libphonenumber:
Change the path of the <script src="">
in the html pages to point to wherever base.js is located
Update javascript/build.xml
with the correct paths
Run the unit tests to make sure everything is working. Open the following pages with your web browser: javascript/i18n/phonenumbers/phonenumberutil_test.html
javascript/i18n/phonenumbers/asyoutypeformatter_test.html
Run the demo: javascript/i18n/phonenumbers/demo.html
Build Closure's compiler.jar: ant -f ~/src/closure-compiler/build.xml
Compile the demo.js and all its dependencies to one file: demo-compiled.js
: ant -f javascript/build.xml compile-demo
Run the compiled demo: javascript/i18n/phonenumbers/demo-compiled.html
To use and compile the library in your own project, use the javascript/i18n/phonenumbers/demo.js
as an example. You will need to goog.exportSymbol all the methods you use in your html so that the compiler won't rename them. You can then invoke the compiler similarly to how the compile-demo ant target in javascript/build.xml
invokes it.
The JavaScript library is ported from the Java implementation (revision 536). When the Java project gets updated follow these steps to update the JavaScript project:
tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar
by running: mvn -f tools/java/java-build/pom.xml package
resources/PhoneNumberMetadata.xml
run the following commands to regenerate metadata.js
and metadatafortesting.js
:ant -f java/build.xml build-js-metadata
demo-compiled.js
used by demo-compiler.html
(TODO: Use target “compile” rather than “compile-demo” once visibility issues for getExtractedNationalPrefix_ have been resolved):
ant -f javascript/build.xml compile-demo
ant -f javascript/build.xml lint