Fix bone-headed link_to change
This commit is contained in:
parent
b20d855f2c
commit
ed5236ef37
|
@ -25,7 +25,7 @@ Feature: i18n Links
|
||||||
Page: <%= t(:msg) %>
|
Page: <%= t(:msg) %>
|
||||||
<% data.pages.each_with_index do |p, i| %>
|
<% data.pages.each_with_index do |p, i| %>
|
||||||
<%= link_to "Current #{p}", "/#{p}" %>
|
<%= link_to "Current #{p}", "/#{p}" %>
|
||||||
<%= link_to "Other #{p}", "/#{p}", ::I18n.locale == :en ? :es : :en %>
|
<%= link_to "Other #{p}", "/#{p}", lang: ::I18n.locale == :en ? :es : :en %>
|
||||||
<% end %>
|
<% end %>
|
||||||
"""
|
"""
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
# Current Version
|
# Current Version
|
||||||
# @return [String]
|
# @return [String]
|
||||||
VERSION = '3.3.13' unless const_defined?(:VERSION)
|
VERSION = '3.3.14' unless const_defined?(:VERSION)
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,9 +58,20 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
||||||
::I18n.t(*args)
|
::I18n.t(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to(text, target, lang=::I18n.locale)
|
def link_to(*args, &block)
|
||||||
url = extensions[:i18n].localized_path(target, lang)
|
options = args.extract_options!
|
||||||
url ? super(text, url) : super(text, target)
|
name = block_given? ? '' : args.shift
|
||||||
|
href = args.first
|
||||||
|
|
||||||
|
lang = options.delete(:lang) || ::I18n.locale
|
||||||
|
|
||||||
|
url = extensions[:i18n].localized_path(href, lang)
|
||||||
|
new_args = []
|
||||||
|
new_args << name unless block_given?
|
||||||
|
new_args << url || href
|
||||||
|
new_args << options
|
||||||
|
|
||||||
|
super(*new_args, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue