You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

localized_language_select

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localized_language_select

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

h1. LocalizedLanguageSelect

Rails plugin to provide support for localized 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":http://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 locale=de for importing language names 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. The code borrows heavily from the LocalizedCountrySelect plugin. See "localized_country_select":http://github.com/karmi/localized_country_select h2. Install & Usage Install as plugin: $ rails plugin install https://github.com/kristianmandrup/localized_language_select.git Install as gem: Insert in Gemfile gem 'localized_language_select' Then to instal it, run: $ bundle install Then to install the locale files, run: $ rails g localized_language_select:locales This will copy the locale files to your Rails config/locales dir. The files will be called 'language.en.yml' and so on... Note: you can specify which locales using the @--locales@ option, which takes a list of locales. $ rails g localized_language_select:locales --locales da en fr h2. Usage example <%= localized_language_select(:user, :language, [], :include_blank => 'Please choose...') %> will become: Please choose... ------------- Afar ... ZaZa

for the en locale.

h2. Options

@:exclude@ option

  <%= localized_language_select(:user, :language, ['English'], :include_blank => 'Please choose...', :exclude => ['Afrikaans']) %>  

@:only@ option

  <%= localized_language_select(:user, :language, ['English'], :include_blank => 'Please choose...', :only => ['German', 'French']) %>  

h2. Todo - Request

Please add translations for your language!

Would be nice to have at least: German, Spanish, Chinese, Japanese, Russian, Indian and Arabic (Persian?) in there as well...

h2. Framework usage

This plugin should also integrate nicely with various formbuilders, including Formtastic

Formtastic example:

<%= semantic_form_for @user do |form| %>  
  ...
  <%= form.input :lang, :as => :language, :priority_languages => ['English'], :include_blank => 'Please choose...', :only => ['German', 'French']) %>    
  ...
<% end %>  

h2. Copyright

Copyright (c) 2009 David Cato, released under the MIT license

FAQs

Package last updated on 14 Jan 2011

Did you know?

Socket

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.

Install

Related posts