github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

karmi / localized_country_select

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 145
    • 10
  • Source
  • Commits
  • Network (10)
  • Issues (3)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails plugin for localized "country_select" helper with Rake task for downloading locales from Unicode.org's CLDR — Read more

  cancel

http://www.restafari.org/localized-country-select.html

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Require hpricot within the rake task itself 
scharfie (author)
Thu Oct 15 03:35:49 -0700 2009
karmi (committer)
Thu Oct 15 04:06:39 -0700 2009
commit  99b494e775e62ce01dd478eda1f2cbb40a115430
tree    364e3cc19f970c81fc158ee24026d74da13b681c
parent  ca5ccd1821a5059bb69afe1ad8ba5b03710f34e5
localized_country_select /
name age
history
message
file .gitignore Wed Oct 22 08:36:16 -0700 2008 Initial commit [karmi]
file MIT-LICENSE Wed Oct 22 08:36:16 -0700 2008 Initial commit [karmi]
file README.rdoc Tue Dec 09 00:12:44 -0800 2008 Fixed wrong method names in documentation [karmi]
file Rakefile Wed Jul 01 00:46:22 -0700 2009 Loaded plugin specific "import:country_select" ... [karmi]
file init.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [karmi]
file install.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [karmi]
directory lib/ Wed Sep 30 02:50:46 -0700 2009 FIX that countries beginning with accented char... [karmi]
directory locale/ Wed Sep 30 02:33:44 -0700 2009 We need Czech locale file for running the tests [karmi]
directory tasks/ Thu Oct 15 04:06:39 -0700 2009 Require hpricot within the rake task itself [scharfie]
directory test/ Wed Sep 30 02:50:46 -0700 2009 FIX that countries beginning with accented char... [karmi]
file uninstall.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [karmi]
README.rdoc

LocalizedCountrySelect

Rails plugin to provide support for localized <select> menu with country names and for storing country information as country code (eg. ‘es’), not name (eg. ‘Spain’), in the database.

Uses the Rails internationalization framework (I18n, rails-i18n.org) for translating the names of countries. Requires Rails 2.2 (released November 21st, 2008) or later versions. Country names are loaded from hashes in plugin directory, according to I18n.locale value.

You can easily translate country codes in your application like this:

    <%= I18n.t @user.country, :scope => 'countries' %>

Comes with a Rake task rake import:country_select ‘de’ for importing country names from Unicode.org’s CLDR repository (www.unicode.org/cldr/data/charts/summary/root.html) Don’t forget to restart the application when you add new locale.

ActionView helper code is adapted from Rails’ default country_select plugin (previously in core). See github.com/rails/country_select/tree/master/lib/country_select.rb

Example

    <%= localized_country_select(:user, :country, [], :include_blank => 'Please choose...') %>

will become:

    <select name="user[country]" id="user_country">
    <option value="">Please choose...</option>
    <option disabled="disabled" value="">-------------</option>
    <option value="AF">Afghanistan</option>
    ...
    <option value="ZW">Zimbabwe</option>
    </select>

for the en locale.

Other resources

  • github.com/rails/country_select (Default Rails plugin)
  • github.com/russ/country_code_select (Stores country code, not name)

Copyright © 2008 Karel Minarik (www.karmi.cz), released under the MIT license

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server