Skip to content

How Dynamic Pages work with Localization (i18n) #637

@rhoulay

Description

@rhoulay

Hi, I try use Dynamic Pages work with Localization (i18n) but no success.

Can generate pages in config.rb from data/article.yml like:

data.article.en.each do |article|
  page "/en/article/#{article.title.parameterize}.html", :proxy => "/generatetemplate/article-template.html", :ignore => true do
    @article_title = article.title
    @article_author = article.author
    @article_text = article.text
    @article_about_author = article.about_author
  end
end
data.article.de.each do |article|
  page "/de/article/#{article.title.parameterize}.html", :proxy => "/generatetemplate/article-template.html", :ignore => true do
    @article_title = article.title
    @article_author = article.author
    @article_text = article.text
    @article_about_author = article.about_author
  end
end

and the article-template.html.erb:

<p><%= @article_author %></p>
<h1><%= @article_title %></h1>
<div><%= @article_text %></div>
<div><%= @article_about_author %></div>

The problem is Middleman don't know the generated page's language, so if use partials like:

<%= link_to I18n.t("menu.article"), "/#{I18n.locale}/article.html" %>

Middleman only generate all page as language english.

How can I use Dynamic Pages work with Localization (i18n)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions