Make a blog multilingual

I am using Liebling theme to make the blog multilingual, allowing the user to choose the language in which he wants to display the blog. To make this improvement I have been inspired by the official documentation as well as this post (https://www.usepine.com/blog/en/creating-a-multi-language-theme/).

As I have the code now, the blog is allowing to see the posts in several languages depending on the url accessed:

/ : shows the page in English with only English posts.

/jp : shows the page in Japanese with only Japanese posts.

/kr: shows the page in Korean with only posts in Korean

However, I run into some problems:

If a user enters the page tags in a language other than English (e.g: https://www.example.com/jp/tags) it is not properly displaying the information as the template is not receiving the data correctly (although it is defined that when accessing that url the page-tags template is displayed), the web is not displaying the title of the page, i.e. it is not receiving the information related to the post block:

page-tags.hbs

{{#post}}
    <div>
      <h1>{{title}}</h1>
    </div>
  {{/post}}

On the other hand, the same thing happens when we want to access to a specific tag https://www.example.com/jp/tag/something), in this case, it is not collecting the data of that tag to be able to show information.

I think to solve this problem, I need to modify Ghost routes from routes.yaml , so that something like this can be defined:

routes:
    /jp/tag/{slug}/:
        template: tag
        controller: channel
        data: tag.{slug}

So that the tag.hbs template can receive the data from the particular tag being accessed via the url …/jp/tag/something.

Currently my routes.yaml file looks like this:

routes:
    /jp/tags/:
        template: page-tags
        controller: channel
    /cn/tags/:
        template: page-tags
        controller: channel
    /kr/tags/:
        template: page-tags
        controller: channel
collections:
    /:
        permalink: /{slug}/
        template: index
        filter: 'tag:-[hash-cn,hash-jp,hash-kr]'
    /kr/:
        permalink: /kr/{slug}/
        template: index-kr
        filter: 'tag:hash-kr'
    /cn/:
        permalink: /cn/{slug}/
        template: index-cn
        filter: 'tag:hash-cn'
    /jp/:
        permalink: /jp/{slug}/
        template: index-jp
        filter: 'tag:hash-jp'

taxonomies:
    tag: /tag/{slug}/
    author: /author/{slug}/

Is there any way to solve this problem? How do I get to represent the template with the right data when accessing a url that is in a different language than the default (English)?

Thank you.

3 Likes