I hope you are doing well. I am working on my Shopify store and I am using a product description through a section that I have created and added to the product.liquid. I am trying to modify the description depending on the language the client is using so it shows the description in a different language.
Here is the code I am using:
{% if request.host contains 'storename.com/es' %}
<div class="tienda-questions">
<div class="tienda-questions-product">
...
</div>
</div>
{% endif %}
So the tricky part comes when I use the {% if request.host contains ‘storename.com/es’ %}
When I use the same code based on the product.title the code seems to work perfectly showing the other description in a different language, by using {% if product.title == "product name" %}
I was wondering if anybody has experience with this and knows what request or value could I use to get it right and modify my section according to language.
Thank you for the help in advance!
2
Answers
You can use {{ request.host }} and {{ request.path }} to get full page url, and then usign conditional statement set specific code
Also to get customer locale, you can try to get by using {{ request.locale.name }}
You may try this:
And something more efficient for multiple languages:
However, usually with multilingual system your product description should be already displayed automatically in the right language so I’m not sure why this kind of code is useful.