Doubt in translating the Casper Theme into Spanish and Portuguese. And I have doubts about making multilingual. Can you help me please?

Hello guys, how are you all doing? I wish you all are well.

Can you help me with this question below, please.

Doubt in translating the Casper Theme into Spanish and Portuguese. And I have doubts about making multilingual.

I created the locales folder and insert the languages ​​as mentioned in this document WorldCasper2/locales at i18n-translatable-frontend · juan-g/WorldCasper2 · GitHub

Here are the json I inserted
bec@ip-172-26-4-105:/var/www/ghost/content/themes/casper/locales$ ls
en.json es.json pt-BR.json

I already restarted the ghost in the sequence, but in the adm of my ghost does not appear what I need to do? Can you help me please?

I created the paging and navigation files in the partials folder.
bec@ip-172-26-4-105:/var/www/ghost/content/themes/casper/partials$ ls
header-background.hbs navigation.hbs post-card.hbs site-nav.hbs
icons pagination.hbs site-header.hbs subscribe-form.hbs

In these two topics below here I have doubts on how to proceed, can you help me please.

5. Use the translation helper

Any plain text in your theme must be wrapped in the {{t}} translation helper, with {{t to the left of the text and }} to the right.

Look for any plain text in all of your theme’s .hbs template files and ensure the translation helper is present.

6. Declare language in HTML

It’s advisable to add the HTML lang attribute to the " <html> " tag at the start of the theme’s default.hbs template, using Ghost’s {{@site.lang}} helper: <html lang="{{@site.lang}}"> . {{@site.lang}} will automatically be replaced on the site with the corresponding language locale tag set in Ghost admin.

I await help, please.

Hi @Carlos_Brandao,

I think you’ve misunderstood what locales do within Ghost and how to set up a multi-language site in Ghost. The locales files are designed to provide alternative languages to use on your site, they aren’t designed to be used together as part of a multi-language site.

The steps you should take in this case it to install WorldCasper2 as a whole theme, not just the json files. WorldCasper2 has been built to use those locales files, and has used the translate helper ({{t}}) throughout. The next thing to do is to set the Publication Language to be your main language by typing in the language code. If your main language for the site is Spanish then you should type “es” in the field.

If you’re wanting to use your site with multiple languages, as a multi-language site, then you’ll need to create new templates that overwrite the main templates you have where necessary. We’ve written about both concepts over in our docs and in our guides. Here’s some direct links for you:

Hope this clears things up for you! :v:

Hi David, I believe the ghost translation part must have worked, I think.

Thank you for your help.

Now about multilingual I changed the routes.yaml file as mentioned in the documentation, now ask me another question is in item 2 of this documentation can you help me? I want to do the right things, I’m new to ghost and doing it right is too important, that’s my opinion.

Can you help or guide me in topic 2 of the link above, please.

1 Like

How familiar are you with front-end development? If you have some experience I’d like to know more specifically where you’re getting stuck on the step. The steps do show where in your theme to amend the code, but maybe you’re unsure which files to edit? Or how to locate these lines of code? With that feedback I can give you more guidance, plus I can update the tutorial to you help you and others use it.

If you don’t have much experience then you may benefit from getting someone from the community to help you with some paid work? Just an idea as this community is thriving with people who are very experienced with Ghost and can provide you with a theme that’s catered for your needs. :blush:

Hi David, how are you? And thank you very much for returning.

As for my experience in the front-end, it is very small, but I managed to work with your documentation related to other topics. Here I was stuck with turning my blog into multilingual for Portuguese and Spanish. I would like to have my blog with the main page in Portuguese with posts in Portuguese and a page in Spanish with posts in Spanish, because I am very fond of Ghost, and I will be very sincere I am new here, but very fond of Ghost.

That’s why it helps those less experienced with ghost.

Thanks again for the replies.

No problem @Carlos_Brandao. If you don’t have much front-end experience I would recommend seeking help from someone with more knowledge that you can pay for the development work. It’s a very common practice and yields a better result.

However if you’re still wanting to continue alone with the guide then let us know the specific parts you’re struggling with :slight_smile:

Hi David, I really appreciate your help.

And I want to figure out how to do things around here even if it takes me longer. So it forces my learning.

I’m stuck in this part here - 2 - Create templates for translated collections, or rather I am as a doubt in this item I have to change in 4 hbs files being them, default, post, page and index. And I saw that I need to create index-de that can be index-es (Spanish). Am I sure of my understanding?

Thats right. For your case you need to duplicate your index.hbs template file into an index-es.hbs template, and then follow the steps to apply the lang value. There’s a good example in the tutorial, however you need to use es instead of de. The tutorial uses German (language code de) as the additional language, but for you your additional language is Spanish so you’ll need to do the same but with es instead. Hope that makes sense!

I will act here, and after this I will return to you shortly informing you how was the stage. OK!

1 Like

Hi David, how are you? I followed the guidelines for transforming the ghost into other languages.

I followed item 2 of the documentation

And it generated this error when accessing my ghost >> Oops, seems there is an error in the error template.

Encountered the error:
[error.hbs] Missing helper: “foreach”
whilst trying to render an error page for the error:
[error.hbs] Missing helper: “foreach”

Follow my step by step that I did according to the documentation.

  1. default.hbs > Replaces for <html lang=“{{{block “lang”}}}”>
    as in the image below
    Captura de Tela 2020-05-05 às 16.14.09

  2. index.hbs > Insert {{#contentFor “lang”}}{{@site.lang}}{{/contentFor}}
    as in the image below Captura de Tela 2020-05-05 às 16.19.39

  3. index-es.hs chosen language > Insert {{#contentFor “lang”}}es{{/contentFor}} as in the image below Captura de Tela 2020-05-05 às 16.22.44

  4. post.hbs and page.hbs > insert Captura de Tela 2020-05-05 às 16.24.56 and Captura de Tela 2020-05-05 às 16.27.23

In your opinion, what I did that may have given this error. Can you help me please.

Captura de Tela 2020-05-05 às 18.35.09

Not sure if this is right, but your template file should be called index-es.hbs not index-es.hs. That could be the error?

The error itself mentions OPEN_ENDBLOCK and Missing helper: "foreach", which makes me think there’s a foreach block helper in your index-es template that hasn’t been correctly stated. If you need some reference points we have our handlebars doc on the foreach helper here:

I’m sorry I wrote the index-es.hbs wrong. See the image Captura de Tela 2020-05-06 às 11.18.12.
I will now act on the new documentation you sent me. Thank you very much and soon I will return to you.

1 Like

Hello David,

how do we dynamically switch the locale going between different language collections?


You want to be changing the lang value in the template, not the locale in Ghost admin. If you check out the aforementioned tutorial it’ll show you how to achieve this:

David, thank you for your patience with us beginners. I’ve read the tutorial several times before starting, but understanding comes in layers, like peeling an onion. I’ve come to appreciate the tutorial, as I begin to understand how the whole thing works.

I’ve now taken care of navigation at all levels and I’m come to parts that are already translated via the {{t}} helper. However, {{t}} works from site language, not the dynamic choice. This means I would need to edit out all the {{t}} translations and replace them with baked-in strings. That somehow seems a huge step back … even vandalism against all the good work done by the theme developer. Is there a way to use {{t}} by explicitly pointing to a translation or some other workaround?

I think “vandalism” is a bit of an extreme choice of words in this case :sweat_smile:. By their very nature themes are designed to be a basis for which you develop to your own needs and wants. Rather than overwriting you could modify and extend on templates using the same techniques I mentioned above with the block and contentFor helpers as well as partials. There might not even be a need to replace the {{t}} helpers in most cases :blush: