Hi, I want to make a certain theme translated into Indonesian language.
I’ve already read a tutorial posted here
Here’s what I’ve done
- Create a
locales
folder and add language files
I’ve made a folder named ‘locales’ inside the theme folder.
- (Manually) translate included sentences on the left side into target language
I’ve manually translated it all.
{
"Back": "Kembali",
"Newer Posts": "Artikel selanjutnya",
"Older Posts": "Artikel sebelumnya",
"Page {page} of {pages}": "Halaman {page} dari {pages}",
"Subscribe": "Langganan",
"Subscribe to {blogtitle}": "Langganan ke {blogtitle}",
"Subscribed!": "Berhasil berlangganan!",
"with the email address": "dengan alamat email",
"Your email address": "Alamat email Anda",
"You’ve successfully subscribed to": "Anda telah berlangganan ke",
"A collection of posts": "Koleksi artikel-artikel",
"A collection of 1 post": "Koleksi berisi 1 artikel",
"A collection of % posts": "Koleksi berisi % artikel",
"Get the latest posts delivered right to your inbox": "Langganan via email",
"Go to the front page": "Ke halaman depan",
"Latest Posts": "Artikel terbaru",
"Message:": "Pesan:",
"<a href='{url}'>More posts</a> by {name}": "<a href='{url}'>Artikel</a> oleh {name}",
"No posts": "Tidak ada artikel",
" (Page %)": " (Halaman %)",
"Read More": "Selengkapnya",
"Read <a href='{url}'>more posts</a> by this author": "Baca <a href='{url}'>artikel lainnya</a> oleh penulis ini",
"Ref:": "Ref:",
"See all % posts": "Lihat % artikel seluruhnya",
"Share this": "Bagikan",
"Stay up to date! Get all the latest & greatest posts delivered straight to your inbox": "Dapatkan artikel terbaru yang dikirim ke email Anda",
"This post was a collaboration between": "Artikel hasil kolaborasi antara",
"youremail@example.com": "alamat.email.anda@domain.com",
"1 post": "1 artikel",
"% posts": "% artikel",
"1 min read": "Bacaan 1 menit",
"% min read": "Bacaan % menit"
}
- Enable blog language
I’ve enabled the blog language on the general settings of the blog.
- Ensure templates exist
I’ve made sure that the pagination.hbs - exists in content/themes/mytheme/partials
according to the template and the navigation.hbs - exists in content/themes/mytheme/partials
according to the template
<ul class="nav">
{{#foreach navigation}}
<li class="{{link_class for=(url) class=(concat "nav-" slug)}}"><a href="{{url absolute="true"}}">{{label}}</a></li>
{{/foreach}}
</ul>
and
<nav class="pagination">
{{#if prev}}
<a class="newer-posts" href="{{page_url prev}}"><span aria-hidden="true">←</span> Newer Posts</a>
{{/if}}
<span class="page-number">Page {{page}} of {{pages}}</span>
{{#if next}}
<a class="older-posts" href="{{page_url next}}">Older Posts <span aria-hidden="true">→</span></a>
{{/if}}
</nav>
However, I can’t comprehend the next steps on the tutorial. It is said that I have to
- 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.
- 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.locale}}
helper: <html lang="{{@site.locale}}">
. {{@site.locale}}
will automatically be replaced on the site with the corresponding language locale tag set in Ghost Admin.
My question is
-
How to wrap the plain text using {{t}} translation? I mean, how to do it correctly? It is said that I have to put {{t}} into every plain text (or any file inside the theme folder with .hbs format). I’ve done that but when I upload the theme on the Ghost admin, it failed.
-
Where do I put the html lang attribute on the default.hbs template? I mean, where on the line of the code? I’m really clueless. It was said that the default.hbs also became one the source of error when I uploaded it but I have no idea where it failed.
p.s I have no experience in coding and so on. so, please educate me step by step.
Thank you so much.