public
Description: Rails plugin for localized "country_select" helper with Rake task for downloading locales from Unicode.org's CLDR
Homepage: http://www.restafari.org/localized-country-select.html
Clone URL: git://github.com/karmi/localized_country_select.git
name age message
file .gitignore Wed Oct 22 08:36:16 -0700 2008 Initial commit [Karel Minarik]
file MIT-LICENSE Wed Oct 22 08:36:16 -0700 2008 Initial commit [Karel Minarik]
file README.rdoc Tue Dec 09 00:12:44 -0800 2008 Fixed wrong method names in documentation [Karel Minarik]
file Rakefile Wed Jul 01 00:46:22 -0700 2009 Loaded plugin specific "import:country_select" ... [Karel Minarik]
file init.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [Karel Minarik]
file install.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [Karel Minarik]
directory lib/ Tue Dec 09 00:12:44 -0800 2008 Fixed wrong method names in documentation [Karel Minarik]
directory locale/ Wed Jul 01 00:47:23 -0700 2009 Removed Czech localization file, leaving only E... [Karel Minarik]
directory tasks/ Tue Dec 02 21:59:20 -0800 2008 Fixed bad extraction of country names for Japan... [Karel Minarik]
directory test/ Fri Nov 21 07:08:23 -0800 2008 Merge branch 'master' of git@github.com:karmi/l... [Karel Minarik]
file uninstall.rb Wed Oct 22 08:36:16 -0700 2008 Initial commit [Karel Minarik]

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

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