IntlPhonePicker
https://rubygems.org/gems/intl_phone_picker
IntlPhonePicker is a ruby gem which allow you to change your html5 "tel" fields into jQuery international phone number pickers.
Feel free to contribute and add your own config translation files through pull requests ! If you want to add a tranlation file, just put it into config/locales ! Or if you can't just send us by email, we will do it for you.
Currently supported languages : US (default), FR. The gem takes the language of the locale from your project.
Sources
- Javascript based library : https://github.com/Bluefieldscom/intl-tel-input
- Ruby based gem : https://github.com/ispyropoulos/intl-tel-input-rails
- French language generator : https://github.com/harold-s/harold-s/tree/master/intl-tel-input-french-translation
Installation
Add this line to your application's Gemfile:
gem 'intl_phone_picker'
And then execute:
$ bundle
Or install it yourself as:
$ gem install intl_phone_picker
To use javascript and stylesheet libraries you need to add :
-
In application default stylesheet file :
*= require intlTelInput
-
In application default javascript file :
//= require intlTelInput
- Coffeescript version :
#= require intlTelInput
- Optionnal : if you want to convert all the country names into French :
//= require intlTelInputFrench
Usage
-
To call intlTelInput input :
<%= intl_phone_tag([your_specific_name]) %>
-
Example :
<%= intl_phone_tag('test') %>
-
To use with a model (Activerecord) :
<%= f.intl_phone_input(:phone) %>
Options
- If you want to enable an hidden field which store the international number of your field :
<%= intl_phone_tag('test', hidden_intl_field: :full_phone) %>
- Activerecord way (Don't forget to create the named accessor in your model, full_phone in this example) :
<%= f.intl_phone_input :Phone, { hidden_intl_field: :full_phone } %>
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/intl_phone_picker/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request