How to use translated ressource in javascript

CatchAlive
New Member
1 0 0

I am trying to fetch the translated text from a translation supported ressource, and use it in "theme.js" file.

When I look at tutorial https://shopify.dev/tutorials/develop-theme-localization-organize-translation-keys it looks like, it should be possible to write:
var link = '<a href="#">' + layout.navigation.more_html + '</a>';"

But it does not work. In liquid files, this works: {{ 'cart.general.taxes_and_shipping_at_checkout' | t }}

Do I have to "preload" the translated in the theme.strings.xxxxxx ?

Thanks
Martin

0 Likes