---
title: 'Multi-Language. TWIG in JS'
url: 'https://getgrav.org/forum/support/multi-language-twig-in-js-t5203'
markdown: 'https://getgrav.org/forum/support/multi-language-twig-in-js-t5203.md'
date: '2026-06-21'
description: "I use Grav and Gantry Helium. I have a function // Handle a click on the hint button hintButton.addEventListener('click', function () { if (score >= 3) { score"
---

[Support](https://getgrav.org/forum/support)

#  Multi-Language. TWIG in JS 

  Started by Dima 2 years ago · 4 replies · 399 views    

 [2 years ago](https://getgrav.org/forum/support/multi-language-twig-in-js-t5203#post-39212 "Permalink") 

I use Grav and Gantry Helium.

I have a function

// Handle a click on the hint button
hintButton.addEventListener('click', function () {
if (score >= 3) {
score -= 3;
scoreElement.textContent = score;
hintImage.style.display = 'block';
setTimeout(() => {
hintImage.style.display = 'none';
}, 12000);
} else {
showNotification('Text Text Text Text', 'error');
}
});

How to showNotification 'Text Text Text Text' in different languages?

In user/languages/ I have de.yaml en.yaml.

Me and claude.ai haven't found a solution yet(.

 [2 years ago](https://getgrav.org/forum/support/multi-language-twig-in-js-t5203#post-39213 "Permalink") 

I think you're trying to solve it the other way around. Try JS in Twig. Set JS variables for your strings in twig and then use them in JS. At least that's how I'd do

 [2 years ago](https://getgrav.org/forum/support/multi-language-twig-in-js-t5203#post-39215 "Permalink") 

Hi, you can add translations to languages.yaml file in your theme folder

example:

```yaml
en:
  THEME_NAME:
    TEXT: 'Text EN!’

de:
  THEME_NAME:
    TEXT: 'Text DE!’
```

then use it in your templates .html.twig

```twig
{{ 'THEME_NAME.TEXT’ | t }}
```

live example - press copy/kopiuj button en/pl:

<https://step-bud.pl/en/contact>

 [2 years ago](https://getgrav.org/forum/support/multi-language-twig-in-js-t5203#post-39216 "Permalink") 

This doesn't answer the question. You can't use twig in JS

 [2 years ago](https://getgrav.org/forum/support/multi-language-twig-in-js-t5203#post-39217 "Permalink") 

thats why I propose possible solution and use translations in .html.twig

[Log in](https://getgrav.org/login?return=%2Fforum%2Fsupport%2Fmulti-language-twig-in-js-t5203) to reply.

###  Suggested topics

 | Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| [it's no possible sign in with email......](https://getgrav.org/forum/support/it-s-no-possible-sign-in-with-email-t9462)    [Support](https://getgrav.org/forum/support) · by webmasterodp, 1 week ago |  | 4 | 169 | [1 week ago](https://getgrav.org/forum/support/it-s-no-possible-sign-in-with-email-t9462 "by webmasterodp") |
| [Site stopped working overnight - 'not writeable' error](https://getgrav.org/forum/support/site-stopped-working-overnight-not-writeable-error-t9445)    [Support](https://getgrav.org/forum/support) · by nwhitfield, 1 week ago |  | 2 | 147 | [1 week ago](https://getgrav.org/forum/support/site-stopped-working-overnight-not-writeable-error-t9445 "by pamtbaau") |
| [MIgrating to 2.0](https://getgrav.org/forum/support/migrating-to-2-0-t9437)    [Support](https://getgrav.org/forum/support) · by stell, 3 weeks ago |  | 5 | 379 | [2 weeks ago](https://getgrav.org/forum/support/migrating-to-2-0-t9437 "by stell") |
| [Render thumbnail in Flex object list view](https://getgrav.org/forum/support/render-thumbnail-in-flex-object-list-view-t9410)    [Support](https://getgrav.org/forum/support) · by gravinator, 1 month ago |  | 5 | 572 | [2 weeks ago](https://getgrav.org/forum/support/render-thumbnail-in-flex-object-list-view-t9410 "by bde") |
| [Home page jumps to modular page on desktop browsers](https://getgrav.org/forum/support/home-page-jumps-to-modular-page-on-desktop-browsers-t9434)    [Support](https://getgrav.org/forum/support) · by Gravver, 3 weeks ago |  | 6 | 356 | [3 weeks ago](https://getgrav.org/forum/support/home-page-jumps-to-modular-page-on-desktop-browsers-t9434 "by Gravver") |
