Multi-language blog with a multi-language theme

I’d recommend looking into using JavaScript and the local storage API to store the last language they viewed on your site. Check out the MDN docs for more info:

@DavidDarnes, @lobo - Thanks for the discussion you two had here.

I also arrived at that point, I wanted /ru to enable displaying only Russian posts but also have the UI elements translated with the help of theme provided locales. This would have been neat and good to maintain. In a perfect world the language reported by the browser would command the language for the ui, or if present, content.

Reading this thread I also conclude that ghost requires hardcoding the translations…in 2021. Feels like multi-language usage is more of an afterthought and ghost is focused more on creating a frontend for mono-lingual paid content, with also the Portal and eMail using hardcoded language strings.

This is great, cost free software for self-hosting - yet it will be harder for German or Russian speaking visitor not able to read English for enjoy the site we are preparing.

1 Like

Is this problem still valid with Ghost 4?

Yes, I have seen no change in the UI that would enable multi-lingual usage of ghost and it’s core plugins

Hi @lobo and @DavidDarnes,

Thanks a lot for your clarifying discussion. I was setting up my ghost site for multiple languages and ended up in the same position as @lobo. Content can easily be filtered, but the UI doesn’t change using the “nice” way of using locales.

I don’t want to have multiple templates or hardcoded translation all over my templates. This seems highly inefficient for a production software in 2021.

I know that with the Publication Language in the General Settings the locale works as expected.

Is it not possible to do whatever that variable does in the backend, but taking into consideration the prefix in the /{prefix}/{slug} of the url?

Maybe we can even code it together in ghost and submit the pull request. It is a feature that definitely a lot of users will benefit from.

The locales feature has always been designed for theme UI to switch to another language. I think you’ll have a hard time not creating custom templates for different languages. For example some languages have different writing directions and extended characters that might require different fonts. Just something to consider when trying to approach the development of a multi-language site.

You’re of course welcome to make a contribution to the official Ghost open source project, as long as you follow the guidelines provided here. However I will say that despite this being a feature that’s been requested before, it’s not something that’s be considerably high on the list of needed features in Ghost. Building a site to cater for multiple languages is hard, regardless of the CMS and tools you use. I would take some time to think about the site you’re trying to build and consider what tools on the market will help you achieve that. If multi-language is high on your list maybe you should look into a tool that also has multi-language high on their feature list.

I’m not trying to deter you from using Ghost, I just wanted to help you pick the right tools for the job :blush:

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