Sha256: aa3cddc359ada8ee2f72e7500e186da46fa874c75943c2e551a4331839d0662c

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

module LocalesHelper

  def formatted_locale current_locale = I18n.locale
    I18n.t('helpers.links.locale', current_locale: t("languages.#{current_locale}", locale: current_locale))
  end

  def i18n_helper
    @i18n_helper = begin
      [].tap do |locales|
        I18n.available_locales.each do |locale|
          locales << [ locale.to_s, I18n.t("languages.#{locale}").capitalize ]
        end
      end
    end
  end

  def i18n_helper_link
    @i18n_helper_link = begin
      [].tap do |links|
        i18n_helper.each do |locale, title|
          links << link_to(title, set_locale_path(locale: locale), method: :post)
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i18n_helper-0.0.4 app/helpers/locales_helper.rb
i18n_helper-0.0.3 app/helpers/locales_helper.rb
i18n_helper-0.0.2 app/helpers/locales_helper.rb
i18n_helper-0.0.1 app/helpers/locales_helper.rb