Use locale for link_to flag

v3-stable
Thomas Reynolds 2015-05-16 12:50:39 -07:00
parent ed5236ef37
commit 6502b37934
4 changed files with 17 additions and 11 deletions

View File

@ -1,11 +1,11 @@
master
===
3.3.13
3.4.0
===
* Fix webrick restarts on Ruby 2.2
* Empower link_to in a i18n context
* Empower link_to in a i18n context.
* Add retina files support on automatic_image_sizes
3.3.12

View File

@ -24,8 +24,10 @@ Feature: i18n Links
"""
Page: <%= t(:msg) %>
<% data.pages.each_with_index do |p, i| %>
<%= link_to "Current #{p}", "/#{p}" %>
<%= link_to "Other #{p}", "/#{p}", lang: ::I18n.locale == :en ? :es : :en %>
<%= link_to "Current #{p}", "/#{p}", class: 'current' %>
<%= link_to "Other #{p}", "/#{p}", title: "Other #{p}", locale: ::I18n.locale == :en ? :es : :en %>
<% link_to "/#{p}", class: 'current' do %><span>Current Block</span><% end %>
<% link_to "/#{p}", title: "Other #{p}", locale: ::I18n.locale == :en ? :es : :en do %><span>Other Block</span><% end %>
<% end %>
"""
And a file named "config.rb" with:
@ -35,9 +37,13 @@ Feature: i18n Links
Given the Server is running at "empty-app"
When I go to "/hello.html"
Then I should see "Page: Hello"
Then I should see '<a href="/hello.html">Current hello.html</a>'
Then I should see '<a href="/es/hola.html">Other hello.html</a>'
Then I should see '<a class="current" href="/hello.html">Current hello.html</a>'
Then I should see '<a title="Other hello.html" href="/es/hola.html">Other hello.html</a>'
Then I should see '<a class="current" href="/hello.html"><span>Current Block</span></a>'
Then I should see '<a title="Other hello.html" href="/es/hola.html"><span>Other Block</span></a>'
When I go to "/es/hola.html"
Then I should see "Page: Hola"
Then I should see '<a href="/es/hola.html">Current hello.html</a>'
Then I should see '<a href="/hello.html">Other hello.html</a>'
Then I should see '<a class="current" href="/es/hola.html">Current hello.html</a>'
Then I should see '<a title="Other hello.html" href="/hello.html">Other hello.html</a>'
Then I should see '<a class="current" href="/es/hola.html"><span>Current Block</span></a>'
Then I should see '<a title="Other hello.html" href="/hello.html"><span>Other Block</span></a>'

View File

@ -1,5 +1,5 @@
module Middleman
# Current Version
# @return [String]
VERSION = '3.3.14' unless const_defined?(:VERSION)
VERSION = '3.4.0' unless const_defined?(:VERSION)
end

View File

@ -63,9 +63,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
name = block_given? ? '' : args.shift
href = args.first
lang = options.delete(:lang) || ::I18n.locale
locale = options.delete(:locale) || ::I18n.locale
url = extensions[:i18n].localized_path(href, lang)
url = extensions[:i18n].localized_path(href, locale)
new_args = []
new_args << name unless block_given?
new_args << url || href