# Theme language translation

**URL:** <https://forum.ghost.org/t/theme-language-translation/25126>\
**Category:** Themes\
**Created:** [August 24, 2021, 8:33am UTC](https://forum.ghost.org/t/theme-language-translation/25126 "2021-08-24T08:33:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eghar\_Anugrapaksi](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/eghar_anugrapaksi/32/14757_2.png) [@Eghar\_Anugrapaksi](https://forum.ghost.org/u/Eghar_Anugrapaksi)\
**Post date:** [August 24, 2021, 8:33am UTC](https://forum.ghost.org/t/theme-language-translation/25126/1 "2021-08-24T08:33:25Z")

</div>

Hi, I want to make a certain theme translated into Indonesian language.

I’ve already read a tutorial posted [here](https://ghost.org/docs/themes/helpers/translate/)

Here’s what I’ve done

1. Create a `locales` folder and add language files ✅

I’ve made a folder named ‘locales’ inside the theme folder.

1. (Manually) translate included sentences on the left side into target language

I’ve manually translated it all.

```auto
{
    "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"
}

```

1. Enable blog language

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/7/7221468c56195d054f62ea33f891c33638afe52a.jpeg)

I’ve enabled the blog language on the general settings of the blog.

1. Ensure templates exist

I’ve made sure that the **pagination.hbs** - exists in `content/themes/mytheme/partials` according to the [template](https://github.com/TryGhost/Ghost/blob/main/core/frontend/helpers/tpl/pagination.hbs) and the **navigation.hbs** - exists in `content/themes/mytheme/partials` according to the [template](https://github.com/TryGhost/Ghost/blob/main/core/frontend/helpers/tpl/navigation.hbs)

```auto
<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

```auto
<nav class="pagination">
    {{#if prev}}
        <a class="newer-posts" href="{{page_url prev}}"><span aria-hidden="true">&larr;</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">&rarr;</span></a>
    {{/if}}
</nav>

```

However, I can’t comprehend the next steps on the tutorial. It is said that I have to

1. 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._

1. 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

1. 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.

2. 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.

---

<div class="post-metadata">

**Author:** ![brightthemes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/brightthemes/32/25099_2.png) [@brightthemes](https://forum.ghost.org/u/brightthemes)\
**Post date:** [August 24, 2021, 5:30pm UTC](https://forum.ghost.org/t/theme-language-translation/25126/2 "2021-08-24T17:30:53Z")

</div>

For the translation helper, I will try to give an example.  
You might have a link like this:

```auto
<a href="{{url}}">Read More</a>

```

To use the translation helper you have to change that to:

```auto
<a href="{{url}}">{{t "Read More"}}</a>

```

As for the `lang` attribute, you should have a `<HTML>` tag in the default.hbs, there you can add the locale:

```auto
<html lang="{{@site.locale}}">

```

---

<div class="post-metadata">

**Author:** ![Eghar\_Anugrapaksi](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/eghar_anugrapaksi/32/14757_2.png) [@Eghar\_Anugrapaksi](https://forum.ghost.org/u/Eghar_Anugrapaksi)\
**Post date:** [August 26, 2021, 5:40am UTC](https://forum.ghost.org/t/theme-language-translation/25126/4 "2021-08-26T05:40:21Z")

</div>

Hi! Thank you for the answer!

I’ll try to implement that and come back again if I face another difficulties.

---

<div class="post-metadata">

**Author:** ![Tropipo](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tropipo](https://forum.ghost.org/u/Tropipo)\
**Post date:** [August 26, 2021, 4:08pm UTC](https://forum.ghost.org/t/theme-language-translation/25126/5 "2021-08-26T16:08:24Z")

</div>

Hi ! Please, come back anyway to tell us if it worked, and explain the all process, step by step, if you can. It would be much appreciated

Because I have the same problem to translate my Theme (Ghost) and have no knowledge of coding.

Thank you !

---

<div class="post-metadata">

**Author:** ![velocipta](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/velocipta/32/14867_2.png) [@velocipta](https://forum.ghost.org/u/velocipta)\
**Post date:** [August 31, 2021, 3:41pm UTC](https://forum.ghost.org/t/theme-language-translation/25126/6 "2021-08-31T15:41:23Z")

</div>

Hi there,

I´m having the same problem. Following the Ghost tutorial [here](https://ghost.org/docs/themes/helpers/translate/), trying out without sucess to translate to pt.

> I´m following “religiously” the steps, yet not working, even after restarting Ghost in the shell.  
> Let´s see, following the bullet points of the Ghost tutorial:  
> 1- the folder locales (presumably not “locale” as it is shown in html) is created, not in the theme folder, but under the main branch.  
> 2-3 - I have created the en.json and the pt.json files. After restarting Ghost the result is inexistent, having the General settings of Ghost admin language (pt) being changed for a long time now, in production and locally. In regard to this, and checking the .json files I see translation between commas, and not quite within the {{t}} helpers. What is exactly the difference?  
> 4 - Also in relation with pagination.hbs and navigation.hbs I have created the files accordingly pulled from GitHub, still with no sucess.  
> 6 - Also in the default.hbs I can see the `<html lang="{{@site.locale}}">.` but still with no results.  
> 7 - All of this was tested after ghost restart in the prompt Shell of Visual Code.
> 
> Can I get clarification of what might be wrong in and about each one of these steps, please?

Further Note: I have copied the locales folder to the theme folder, after reading this forum thread, and still without results. Also, I edited in the the default.hbs file in the theme (London) folder an instance of {{t}} translation, and also it did not work. I was very careful in making sure I had the same instance coded in the corresponding pt.json file, which in the case was “Published with”. Still with no results.

---

<div class="post-metadata">

**Author:** ![Tropipo](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tropipo](https://forum.ghost.org/u/Tropipo)\
**Post date:** [September 3, 2021, 12:34pm UTC](https://forum.ghost.org/t/theme-language-translation/25126/7 "2021-09-03T12:34:07Z")

</div>

Hello !

In another tread in the forum, someone says it has created a tool 😜 **[GitHub - biswajit-saha/ghost-theme-translator: CLI tool for automatically parse translatable strings in Ghost theme and generate language file.](https://github.com/biswajit-saha/ghost-theme-translator)**  
I haven’t tested it yet

I have a newbie question : when you write your code, in which file/aplication do you write it in ? Textedit (I’m on Mac) ? Or do you use a code editor like VisualStudio code ???

Thanks ! Have a good day all

---

<div class="post-metadata">

**Author:** ![raragao](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/raragao/32/15398_2.png) [@raragao](https://forum.ghost.org/u/raragao)\
**Post date:** [October 12, 2021, 1:51am UTC](https://forum.ghost.org/t/theme-language-translation/25126/8 "2021-10-12T01:51:23Z")

</div>

@velocipta , do you reach some solution? I’ve had the same behavior.
