How to host the google libphonenumber locally?

后端 未结 3 1459
盖世英雄少女心
盖世英雄少女心 2020-12-28 21:40

During development on my localhost, I am trying to self host the libphonenumber library. I am trying with the following:



        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 22:09

    You may have solved this already, but I found a really easy way to compile all the libphonenumber code into one file that includes closure library stuff.

    Go to http://closure-compiler.appspot.com/home

    This is Google's online version of the closure compiler.

    Then input something like:

    // ==ClosureCompiler==
    // @compilation_level SIMPLE_OPTIMIZATIONS
    // @output_file_name libphonenumber.js
    // @use_closure_library true
    // @code_url https://raw.githubusercontent.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/phonemetadata.pb.js
    // @code_url https://raw.githubusercontent.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/phonenumber.pb.js
    // @code_url https://raw.githubusercontent.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/metadata.js
    // @code_url https://raw.githubusercontent.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/phonenumberutil.js
    // @code_url https://raw.githubusercontent.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/asyoutypeformatter.js
    // @formatting pretty_print
    // ==/ClosureCompiler==
    

    You can add or delete any extra files you want.

    Then click Compile.

    This will retrieve each of the latest files from the repository and build it into a single javascript file.

    Now you don't need to worry about handling all the closure library code, as what you will need has already been compiled in.

    Hope this helps.

    Edit: I find that this is really useful for handling updates to the library as well. If you just rerun this in the compiler, you will get your new javascript file with all the latest updates.

提交回复
热议问题