Sha256: e681dfa5dd9849ccf44d07c56683f7f2a2877de1b49198af59fd9754869c2bf9

Contents?: true

Size: 827 Bytes

Versions: 6

Compression:

Stored size: 827 Bytes

Contents

# gettext_plugin.rb - a sample script for Ruby on Rails
#
# Copyright (C) 2005-2007 Masao Mutoh
#
# This file is distributed under the same license as Ruby-GetText-Package.

module LangHelper
  include GetText

  bindtextdomain("lang_helper", 
        :path => File.join(RAILS_ROOT, "vendor/plugins/lang_helper/locale"))

  def show_language
    langs = I18n.supported_locales.sort
    ret = "<h4>" + _("Select locale") + "</h4>"
    langs.each_with_index do |lang, i|
      ret << link_to("[#{lang}]", :action => "cookie_locale", :id => lang)
      if ((i + 1) % 6 == 0)
	ret << "<br/>"
      end
    end
    ret
  end

  def cookie_locale
    cookies["lang"] = params["id"]
    set_locale params["id"]
    flash[:notice] = _('Cookie &quot;lang&quot; is set: %s') % params["id"]
    redirect_to :action => 'index'
  end
end
 

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gettext_rails-2.1.0 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
gettext_rails-2.0.1 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
gettext_rails-2.0.2 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
gettext_rails-2.0.0 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
gettext_rails-2.0.3 sample/vendor/plugins/lang_helper/lib/lang_helper.rb
gettext_rails-2.0.4 sample/vendor/plugins/lang_helper/lib/lang_helper.rb