Liquid, JavaScript, themes, sales channels
Hi, I'm pretty new with Shopify but already works with twig,
I need to update hardcoded custom code in app.js.liquid by the liquid translated tags. Here's the exemple :
original code :
$('.add_to_cart').text('Make a selection') ;
My code :
$('.add_to_cart').text( "{{ 'layout.general.cart_selection' | t}}" ) ;
But 'layout.general.cart_selection' isn't update with the right translation after switching the language.
I've noticed, that some tgas Like Shopify.translation.unavailable works with language switch. There is a way to register my custom tags as Shopify.translation.cart_selection ?
Thanks for help.
Hi,
You need change your code:
$('.add_to_cart').text( "{{ 'layout.general.cart_selection' | t}}" ) ;
To:
$('.add_to_cart').text({{ 'layout.general.cart_selection' | t | json }});
thanks for your help.
It doesn't work. Does it can be related to the multi-language app (Translate my store) ?
Hello, thanks but this doesnt work for me. It is stuck at the default language and doesnt update when switched. Any help appreciated.
Yes, you can do that. You can follow on this guide: https://shopify.dev/tutorials/develop-theme-localization-use-translation-keys#include-html-in-transl...
Hope this helps.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024