Created
June 5, 2014 11:17
-
-
Save heracek/6149f22b730c1c493f50 to your computer and use it in GitHub Desktop.
Padrino switching multiple-laguages for same page
This file contains 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
- EDIT_LOCALES.each do |locale| | |
- lang_link = (defined?(@page_url) and not @page_url[locale].blank?) ? @page_url[locale] : url(:home, :index, locale: locale) | |
li class='#{locale == I18n.locale ? 'active' : ''}' | |
a href=lang_link | |
= locale.to_s |
This file contains 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
... | |
= partial 'home/language_links' | |
... |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
- @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