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 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: https://ghost.org/tutorials/multi-language-content/
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.
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.
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.
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
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!
And it generated this error when accessing my ghost blog.becinteligencia.com.br >> 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:
undefined
[error.hbs] Missing helper: “foreach”
Follow my step by step that I did according to the documentation.
default.hbs > Replaces for <html lang=“{{{block “lang”}}}”>
as in the image below
index.hbs > Insert {{#contentFor “lang”}}{{@site.lang}}{{/contentFor}}
as in the image below
index-es.hs chosen language > Insert {{#contentFor “lang”}}es{{/contentFor}} as in the image below
post.hbs and page.hbs > insert and
In your opinion, what I did that may have given this error. Can you help me please.
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 .
I will now act on the new documentation you sent me. Thank you very much and soon I will return to you.
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: https://ghost.org/tutorials/multi-language-content/
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 . 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