Created
January 14, 2011 13:33
-
-
Save laurynas/779607 to your computer and use it in GitHub Desktop.
Multi locale field builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# depends on i18n_multi_locales_form plugin | |
# rails plugin install https://github.com/ZenCocoon/i18n_multi_locales_form.git | |
module MultiLocaleFieldBuilder | |
def multi_locale_field(method, opts = {}) | |
opts = { | |
:type => :text_field | |
}.merge(opts) | |
type = opts.delete(:type) | |
html = [] | |
I18n.available_locales.each do |locale| | |
html << self.send(type, method, opts.merge(:locale => locale, :title => locale.to_s.upcase)) + " " + locale.to_s.upcase | |
end | |
html.join('<br />').html_safe | |
end | |
end | |
ActionView::Helpers::FormBuilder.send(:include, MultiLocaleFieldBuilder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment