diff --git a/middleman-core/features/i18n_link_to.feature b/middleman-core/features/i18n_link_to.feature index 9fd29d10..d03c532b 100644 --- a/middleman-core/features/i18n_link_to.feature +++ b/middleman-core/features/i18n_link_to.feature @@ -25,7 +25,7 @@ Feature: i18n Links Page: <%= t(:msg) %> <% data.pages.each_with_index do |p, i| %> <%= 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 %> """ And a file named "config.rb" with: diff --git a/middleman-core/lib/middleman-core/version.rb b/middleman-core/lib/middleman-core/version.rb index 7ca76fd6..24ef9ca0 100644 --- a/middleman-core/lib/middleman-core/version.rb +++ b/middleman-core/lib/middleman-core/version.rb @@ -1,5 +1,5 @@ module Middleman # Current Version # @return [String] - VERSION = '3.3.13' unless const_defined?(:VERSION) + VERSION = '3.3.14' unless const_defined?(:VERSION) end diff --git a/middleman-core/lib/middleman-more/core_extensions/i18n.rb b/middleman-core/lib/middleman-more/core_extensions/i18n.rb index abb8377e..8f88cfef 100644 --- a/middleman-core/lib/middleman-more/core_extensions/i18n.rb +++ b/middleman-core/lib/middleman-more/core_extensions/i18n.rb @@ -58,9 +58,20 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension ::I18n.t(*args) end - def link_to(text, target, lang=::I18n.locale) - url = extensions[:i18n].localized_path(target, lang) - url ? super(text, url) : super(text, target) + def link_to(*args, &block) + options = args.extract_options! + 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