Skip to content

Instantly share code, notes, and snippets.

@heracek
Created June 5, 2014 11:17
Show Gist options
  • Save heracek/6149f22b730c1c493f50 to your computer and use it in GitHub Desktop.
Save heracek/6149f22b730c1c493f50 to your computer and use it in GitHub Desktop.
Padrino switching multiple-laguages for same page
...
= partial 'home/language_links'
...
Src::EditArchitects.helpers do
EDIT_LOCALES = [:cs, :en]
def this_page_url(&url_block)
original_locale = I18n.locale || I18n.defalut_locale
page_url = {}
EDIT_LOCALES.each do |locale|
I18n.locale = locale
page_url[locale] = url_block.call(locale)
end
I18n.locale = original_locale
page_url
end
end
Src::EditArchitects.helpers do
def project_category_url(project_category, locale=nil)
url(:project_category, :show, project_category_slug: project_category.slug, locale: locale)
end
end
- @page_url = this_page_url {|locale| project_category_url(@project_category, locale)}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment