allow bad paths in i18n links. for #850
This commit is contained in:
parent
ca8655744a
commit
5630395b40
|
@ -87,9 +87,15 @@ Feature: i18n Paths
|
|||
msg: Hola
|
||||
home: Casa
|
||||
"""
|
||||
And a file named "source/assets/css/main.css.scss" with:
|
||||
"""
|
||||
$color: red;
|
||||
body { background: $color; }
|
||||
"""
|
||||
And a file named "source/localizable/index.html.erb" with:
|
||||
"""
|
||||
Page: <%= t(:home) %>
|
||||
<%= stylesheet_link_tag :main %>
|
||||
"""
|
||||
And a file named "source/localizable/hello.html.erb" with:
|
||||
"""
|
||||
|
@ -107,11 +113,15 @@ Feature: i18n Paths
|
|||
"""
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
set :css_dir, 'assets/css'
|
||||
set :relative_links, true
|
||||
set :strip_index_file, false
|
||||
activate :i18n, mount_at_root: :en
|
||||
activate :relative_assets
|
||||
"""
|
||||
Given the Server is running at "empty-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "assets/css/main.css"
|
||||
When I go to "/hello.html"
|
||||
Then I should see "Page: Hello"
|
||||
Then I should see '<a class="current" href="index.html">Current Home</a>'
|
||||
|
|
|
@ -63,11 +63,13 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|||
def url_for(path_or_resource, options={})
|
||||
locale = options.delete(:locale) || ::I18n.locale
|
||||
|
||||
should_relativize = options.key?(:relative) ? options[:relative] : config[:relative_links]
|
||||
opts = options.dup
|
||||
|
||||
options[:relative] = false
|
||||
should_relativize = opts.key?(:relative) ? opts[:relative] : config[:relative_links]
|
||||
|
||||
href = super(path_or_resource, options)
|
||||
opts[:relative] = false
|
||||
|
||||
href = super(path_or_resource, opts)
|
||||
|
||||
final_path = if result = extensions[:i18n].localized_path(href, locale)
|
||||
result
|
||||
|
@ -76,8 +78,13 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|||
href
|
||||
end
|
||||
|
||||
options[:relative] = should_relativize
|
||||
super(final_path, options)
|
||||
opts[:relative] = should_relativize
|
||||
|
||||
begin
|
||||
super(final_path, opts)
|
||||
rescue RuntimeError
|
||||
super(path_or_resource, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue