davec / localized_language_select
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
locale/ | ||
| |
tasks/ | ||
| |
test/ | ||
| |
uninstall.rb |
LocalizedLanguageSelect
Rails plugin to provide support for localized <select> menu with language names and for storing language information as language code (eg. ‘sv’), not name (eg. ‘Swedish’), in the database.
Uses the Rails internationalization framework (I18n, rails-i18n.org) for translating the names of languages. Requires Rails 2.2 (released November 21st, 2008) or later versions. Language names are loaded from hashes in plugin directory, according to I18n.locale value.
You can easily translate language codes in your application like this:
<%= I18n.t @user.language, :scope => 'languages' %>
Comes with a Rake task rake import:language_select ‘de’ for importing language 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.
The code borrows heavily from the LocalizedCountrySelect plugin. See github.com/karmi/localized_country_select
Example
<%= localized_language_select(:user, :language, [], :include_blank => 'Please choose...') %>
will become:
<select name="user[language]" id="user_language">
<option value="">Please choose...</option>
<option disabled="disabled" value="">-------------</option>
<option value="aa">Afar</option>
...
<option value="zza">ZaZa</option>
</select>
for the en locale.
Copyright © 2009 David Cato, released under the MIT license

