Multi-language blog with a multi-language theme

There is already a mockup and requirements created as a ticket for this feature: [i18n] Multi-lingual Content Publishing (Mockups) · Issue #8509 · TryGhost/Ghost · GitHub
Would it be possible to pick it up again?
Would be a great addition to Ghost!

I have been trying to translate my site following the same manuals as all of you folks and ended up being SO confused by the way Ghost deals with localization. My blog default language is Spanish and I’m trying to localize it in English. Everything works fine with the setups, I can access the /en index with all my translated posts but the main problems that I have are:

  1. The theme translation problem, I have no idea how to translate things like:
<span class="pagination-info">{{t "Page {page} of {pages}" page=page pages=pages}}</span>

When the strings are static like the previous post’s examples that’s fine, but how to translate dynamic data coming from the theme?

  1. Then, it seems esoteric to me also how to translate blocks of components like the post-nav block at the end of each post detail page. I have translated all of my “post-excerpt” blurbs to English but the post navigation component just shows the excerpts randomly in English and Spanish when I’m in the “/en” part of my site.

So far I haven’t found any way to do that on the manuals even when everything is working fine with my localization setup. I presume it can be done by using {{#has tag="#es"}} / {{#has tag="#en"}}. The fact is I’m not an expert on handlebars and I have failed miserably in every attempt to do this.

  1. I don’t know if you folks have had the same problem but for some reason when I go to /en my site has the title of the site name (which is correct) but with the string “(Page1)” next to it, no idea how to change that or even what’s going on with the weird title on the “/en”.

  2. One Thing that is really confusing to me. My website is in Spanish, that’s the Publication Language. Manuals just mentioned briefly the creation of “index-es” and “index-en” files. The question is do I need to have an “index-lang” file for every language? Every time I test changes on my “index-es.hbs” file nothing changes (I’m assuming I’m still using the regular “index.hbs”). So what do I need the other .hbs file for the default language of my site?

Just to be clear I don’t want Ghost to translate my content, I just want to be able to find a way for my visitors to correctly navigate the English version of my site with a translated Theme and a Language widget to switch between languages.

I will REALLY appreciate your help folks since this is starting to be a really frustrating process. Many Thanks.

1 Like

That was one reason why I moved my blog to Kirby CMS.

2 Likes

I created a site-nav-es.hbs file with the modified texts, which I recall in the index-es.hbs file. Strangely, it works on the contrary, in the original language the texts in Spanish come out and in the Spanish version of the site the texts come out in the original language.

I have to translate all the contents of the website in two other languages, de and fr, do I have to create a file for each language? . .

exactly, I hope they change this logic, I realize it’s not easy, but it would be a big turn on if you could do everything from the backend or if you could change the language by uploading a simple file with all the translations

1 Like

This was a huge problem for us as well, so we managed to put together a solution in a few hours.
We created a custom version of the {{t}} helper, which loads all of the locales/*.json files from a theme and chooses one based on what the user requests as a parameter.

index.hbs

        {{i18n "Hello there" lang="en"}} Kenobi<br>
        {{i18n "Hello there" lang="it"}}Mario<br>
        {{i18n "Hello there" lang=@site.locale}} Mario<br>

locales/en.json

{
    "Hello there": "Hello there, general"
}

locales/en.json

{
    "Hello there": "It's-a me, a-"
}

yielding:

Hello there, general Kenobi
It's-a me, a-Mario
Hello there, general Mario

The changes necessary to achieve this were minimal, so it won’t impact the core too much.
If this is something that the community and the Ghost team would accept (cc @Hannah ), we’d love to make a PR for this.

4 Likes

Hi James, could you share the solution? Suggested by your one sounds good

I’m in the process of writing an article on this, I’ll share it as soon as it’s done! :grinning_face_with_smiling_eyes: :sparkles:

5 Likes

@james.kerber That sounds amazing if it works! Any progress on that article of yours? :grinning_face_with_smiling_eyes:

1 Like

Are there any updates on this?

I would like to add the third and fourth languages to my site.

it is easy to imagine that creating 4 copies of the same file and conditioning with the helpers becomes insane

did you manage to write it? :slightly_smiling_face:

Hey guys, I have created a multilang website with Ghost CMS.

Check it out at here :point_right:t2:https://androidwedakarayo.com

I am not using translation or locale in Ghost. I have used tags, filtering and the routes to make this happen.

1 Like

it would be nice if you could share how to do it in a tutorial :slightly_smiling_face:

then I wanted to ask you out of curiosity which hosting are you using? I with digitalocean I’m having problems with error 504 but there are few users so I don’t understand why

1 Like

I have modified my theme and routes. I will make a tutorial when I got a free time.

1 Like

pls do kindly a tutorial, many thanks in advance

nothing new here? any working solution?

the official https://ghost.org/tutorials/multi-language-content/ is down.

1 Like

I will create a sample theme with Casper and let you all know. But it will take some time because these days I am working on another website.

2 Likes

One more question: Is there a way to use the get-filter do filter out other languages in a dynamic way?


{{#get
            "posts"
            limit="6"
            filter="id:-{{id}}+tag:{{lang}}-{{lang}}" as |related_posts|
          }}

does not work.