Personalized checkout and custom promotions with Shopify Scripts
Hello, I am currently loading an Article dynamically as shown below:
{% assign introductionPath = blog.handle | append: '/introduction' %} {% assign introductionSection = articles[introductionPath] %}
{{ introductionSection.content }} <!-- this shows always the default language -->
although the problem with this approach is that the current locale is completely ignored. Is there any way to rewrite the above script so that I include the current selected locale and load the content with the correct language?
Thank you for the help
Hi @abiratsis
You can refer to this code and check if it works
{% assign introductionPath = blog.handle | append: '/introduction' %}
{% assign introductionSection = articles[introductionPath] %}
{% capture localeContentKey %}{{ introductionPath }}_{{ request.locale | downcase }}{% endcapture %}
{% assign localeContent = introductionSection[localeContentKey] %}
{{ localeContent.content }}
- Found this helpful? Hit "Like" and "Accept as Solution"! - Feeling generous. ☕ Buy me coffee!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify
Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Thank you very much for your answer. Apparently, there is another issue with the code, when I try to print out
request.locale.iso_code
I always get the default locale == en. Do you have any clue why is this happening?
You can try to use this code, it will return the name of the locale in the locale itself.
{{ request.locale.endonym_name }}
- Found this helpful? Hit "Like" and "Accept as Solution"! - Feeling generous. ☕ Buy me coffee!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify
Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Well ok, that will give me English instead of en, but the problem is that when I change to German I still get en, instead of de
Hi @abiratsis
You can try to use this code to get current locale and check if it works for you
{% if content_for_header %}
{% assign locale_info = content_for_header | split: ',"locale":"' %}
{% assign locale_info = locale_info[1] | split: '","' %}
{% assign current_locale = locale_info[0] %}
Current Locale: {{ current_locale }}
{% endif %}
- Found this helpful? Hit "Like" and "Accept as Solution"! - Feeling generous. ☕ Buy me coffee!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify
Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Hello @Dan-From-Ryviu thank you for the answer but that didn't work either.
Let's assume I will manage to extract the current locale from the url, may I ask you where did you get the pattern
{% capture localeContentKey %}{{ introductionPath }}_{{ request.locale.iso_code | downcase }}{% endcapture %}
from? I am asking because when I tried to hardocode the locale this didn't work either. For instance I tried introductionSection['myblog/introduction_en'] and this doesn't work either. So I was wondering if there is a way to get content of an article by specifying locale.
Thank you
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025