
Security News
ESLint Adds Support for Parallel Linting, Closing 10-Year-Old Feature Request
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
country-select-engine
Advanced tools
== CountrySelectEngine
A Rails engine to provide localized country names, languages and currencies. For example, it translates 'en' to 'English' for language, 'USD' to 'US Dollar' for currency and 'US' to 'United States' for country.
It uses Rails internationalization framework (http://rails-i18n.org) for translation. It requires Rails 3.2 or later
You can easily translate country codes in your application like this:
<%= I18n.t 'US', :scope => 'countries' %>
And to create selection menu:
<%= localized_country_select(:user, :country, [], :include_blank => 'Please choose...') %>
will become:
Please choose... ------------- Afghanistan ... ZimbabweYou can do the same for language ('en', 'ja', 'fr', etc.) and currency ('USD', 'GBP', 'EUR', etc.)
== Install
Add this gem in Gemfile of your application
gem 'country-select-engine'
or any variation with :path or :git
== Generating translation files
The translation files are generated through ruby-cldr:
thor cldr:download thor cldr:export --merge
Then 'script/convert_cldr.rb' is used to tidy up.
== Generating translation files (deprecated)
If you want to regenerate your own, in your application, use
rake country_select:import_country[locales]
or in dummy application of this engine
rake app:country_select:import_country[locales]
Country names are imported from Unicode.org's CLDR repository (http://www.unicode.org/cldr/data/charts/summary/root.html)
Don't forget to restart the application when you add new locale.
== ActionView helper
ActionView helper code is adapted from Rails' default country_select plugin (previously in core). See http://github.com/rails/country_select/tree/master/lib/country_select.rb
== Options
@:exclude@ option
<%= localized_country_select(:user, :country, ['English'], :include_blank => 'Please choose...', :exclude => ['Afrikaans']) %>
@:only@ option
<%= localized_country_select(:user, :country, ['English'], :include_blank => 'Please choose...', :only => ['German', 'French']) %>
@:symbol@ option
':symbol => :pretend' to prepend symbol to value in selection ':symbol => :append' to append symbol to value in selection
== Framework usage
This engine should also integrate nicely with various formbuilders, including Formtastic
Formtastic example:
<%= semantic_form_for @user do |form| %>
...
<%= form.input :home_country, :as => :country, :priority_countries => ['USA'], :include_blank => 'Please choose country...', :only => ['USA', 'Germany', 'France']) %>
...
<% end %>
== Copyright
== Other resources
FAQs
Unknown package
We found that country-select-engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.
Security News
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.