Use locale for link_to flag
This commit is contained in:
parent
ed5236ef37
commit
6502b37934
4 changed files with 17 additions and 11 deletions
|
@ -1,11 +1,11 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
3.3.13
|
3.4.0
|
||||||
===
|
===
|
||||||
|
|
||||||
* Fix webrick restarts on Ruby 2.2
|
* 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
|
* Add retina files support on automatic_image_sizes
|
||||||
|
|
||||||
3.3.12
|
3.3.12
|
||||||
|
|
|
@ -24,8 +24,10 @@ 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}", class: 'current' %>
|
||||||
<%= link_to "Other #{p}", "/#{p}", lang: ::I18n.locale == :en ? :es : :en %>
|
<%= 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 %>
|
<% end %>
|
||||||
"""
|
"""
|
||||||
And a file named "config.rb" with:
|
And a file named "config.rb" with:
|
||||||
|
@ -35,9 +37,13 @@ Feature: i18n Links
|
||||||
Given the Server is running at "empty-app"
|
Given the Server is running at "empty-app"
|
||||||
When I go to "/hello.html"
|
When I go to "/hello.html"
|
||||||
Then I should see "Page: Hello"
|
Then I should see "Page: Hello"
|
||||||
Then I should see '<a href="/hello.html">Current hello.html</a>'
|
Then I should see '<a class="current" 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 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"
|
When I go to "/es/hola.html"
|
||||||
Then I should see "Page: Hola"
|
Then I should see "Page: Hola"
|
||||||
Then I should see '<a href="/es/hola.html">Current hello.html</a>'
|
Then I should see '<a class="current" 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 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>'
|
|
@ -1,5 +1,5 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
# Current Version
|
# Current Version
|
||||||
# @return [String]
|
# @return [String]
|
||||||
VERSION = '3.3.14' unless const_defined?(:VERSION)
|
VERSION = '3.4.0' unless const_defined?(:VERSION)
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,9 +63,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
||||||
name = block_given? ? '' : args.shift
|
name = block_given? ? '' : args.shift
|
||||||
href = args.first
|
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 = []
|
||||||
new_args << name unless block_given?
|
new_args << name unless block_given?
|
||||||
new_args << url || href
|
new_args << url || href
|
||||||
|
|
Loading…
Add table
Reference in a new issue