i18n + proxy dynamic pages
Expected behavior and actual behavior
I've seen that there are issues with wontfix tag already with a similar issue, but I have read them and I don't see how the solutions given apply to my problem, so I'm writing a new issue. Sorry for the inconvenience.
I'm trying to duplicate a resource using a proxy. My goal is to generate a copy of some resources (marked with generate_copy: true in the frontmatter) and modify its contens using a variable.
ready do
sitemap.resources.select {|p| p.data[:generate_copy] }.each do |page|
page_lang = page.options[:locale]
if page.instance_of? Middleman::Sitemap::ProxyResource
page = page.target_resource
end
new_path = page.path.gsub(/(.*\/)(.*?)(\..*)/, '\1\2_new\3')
proxy new_path, page.path, :locals => {
:more_content => true
}
endGiven a file source/dir/test.html.erb:
---
generate_copy: true
---
# Test
This is the main content
<% if defined?(more_content) && more_content %>
- This is added content to the copy
<% end %>The previous code works OK and it generates the resource /dir/test_new.html with the added content, which uses the default language and it's not proxied.
However, I've been trying to achieve the same behavior with localized files, but since I18n proxies its resources, an exception is raised because it's not allowed to proxy another proxy.
Given the file source/dir/test.en.html.erb with the same contents, the exception You can't proxy en/dir/test_new.html to dir/test_new.en.html which is itself a proxy. is raised.
The expected behavior would be to be able to generate a copy in /en/dir/test_new.html.
Is any other way to git this to work or bypass this exception?
Thanks.
Source: middleman/middleman