Middleman TagPages template - not getting correct Locale

I set the config correctly

mount   = :"en-gb"
locales = [ :"en-gb", :"fr-be" ]

# I18n
# @see https://middlemanapp.com/advanced/localization/
# @see http://www.rubydoc.info/github/svenfuchs/i18n/I18n
activate :i18n do | i |
  i.locales       = locales
  i.mount_at_root = mount
  # i.path          = "/:locale/"
  # i.lang_map      = { :'en-gb' => 'en-gb', :'fr-be' => 'fr-be' }
end

In the blog extension the path is set

blog.tag_template = "template/tag.html"
blog.taglink      = "{lang}/tag/:tag.html"

Now from the home page I click on a tag and it links through to the correct tag page. i.e. http://localhost:4567/fr-be/tag/tester.html

So you would expect as the locale is in the URL the page would have the correct locale assigned.

However the locale on the template page is set as

Locale
en-gb en-gb

So subsequently the articles pulled in on the Tag pages have the incorrect links when showing the associated tags.

Any help appreciated

Ian

I have created this in Stack overflow - copying here also
https://forum.middlemanapp.com/search?q=tag%20pages%20lang

I can add

-# Set the correct locale

  • current_page.add_metadata options: { locale: “fr-be”, lang: “fr-be” }

But this seems to only work after refreshing the said tag page - and does not build correctly either.

I have now injected the options into the templates pages

##
# Ready hook
# Add options to international template pages
##
ready do

    # Get all the french tags
    sitemap.resources.select{ | d | d.data.template }.each do | resource |

        if resource.path[ 0...5 ] === locale.to_s

            puts locale

            resource.add_metadata options: {
                locale: locale,
                lang:   locale
            }

        end

    end

end

@iwarner by the time you experienced this issue, have you faced issues also on the blog articles selection.

Outside the primary language, by the time I do a select based on the current locale I always get returned english content (first language in my config file).

Below the code I used:
page_articles.select { | a | a.locals[:lang].to_s === I18n.locale.to_sym.to_s }.each do | article |

But more simplistically, a puts articles.count does not return the right value and spit out the total of english content rather than the localised one.

Any idea? I never faced such issues in M3.

I dont know if there are major difference btween blog v3 and v4 to stop this behaviour - I may need to go back and check - but you can also do this too - check the difference between the two branches on this method.

See what we both find

It’s actually an unexplored territory for me. At my time I was using SourceSafe, so need to get up to speed with Git and branches code comparison.
Any indication on where to start in a simple way? If so, happy to invest some time in doing code comparison.

BTW, regardless on the primary language in the I18n, I always got english content returned (but haven’t tried having only other languages different than english though).
This particular issue was solved having two separate blog.lang.html files with the blog: in the frontmatter.

Have followed up in Blog issues - lets keep the convo in one place.

Do share your config please on the following though

“This particular issue was solved having two separate blog.lang.html files with the blog: in the frontmatter”