Additional Script in Checkout page translate?

Additional Script in Checkout page translate?

MarekRipa
New Member
5 0 0

Hi guys,

 

I have a script for a custom payment instructions (bank account transfer). These instructions are visible only if the payment is selected.

 

I'm now trying to figure out how to set the script to two languages as the store is in 2 languages?

 

There is the original code:

 

<script>
{% if checkout.transactions[0].gateway == 'Bank Deposit' %}
Shopify.Checkout.OrderStatus.addContentBox('<h2>Instructions for Bank Account transfer:</h2>',
'<p>X</p>')

{% endif %}
</script>

 

The code works well. But sadly it shows up on both language sites.

 

Any ideas how to do it?

 

Thanks!

Replies 4 (4)

BSS-Commerce
Shopify Partner
3477 464 554

Hi @MarekRipa,

 

In Shopify Theme's code editing, there is a "Locales" folder that allows formatting languages through variables, so you can access it to customize and then insert those variables into the liquid file.

view (29).png

 

As for your case, you only transmit text, so multiple languages are impossible unless your script can handle multiple languages.

Please let me know if you need any further help.

If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here .


B2B Solution & Custom Pricing | Product Labels by BSS


Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency
MarekRipa
New Member
5 0 0

Hi,

 

thanks for your help but can you please be more detailed about the localize?

 

I'm using the script in the Additional Scripts option in Settings -> Checkout.

 

Is there any option to solve this only with the little edit to my script? I saw some other threads that are using this code but when I tried to implement it to my code, It didn't work.

 

{% if request.locale.iso_code contains 'en' %}
<script> english script </script>
 {% elsif request.locale.iso_code contains 'de' %} 
<script> german script </script>
{% elsif request.locale.iso_code contains 'fr' %} 
<script> french script </script>
{% endif %}

 

Thanks!

BSS-Commerce
Shopify Partner
3477 464 554

Hi @MarekRipa.,

view 33.png

For each line highlighted in red, it will be checked what language the website is currently using.

So for each script, the function is the same. But with the text, you will have to re-translate according to each country.

 

Based on your code, I only can explain to you like that. In case you want to have more detailed information, you can kindly share access to your site with me.

If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here .


B2B Solution & Custom Pricing | Product Labels by BSS


Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency
MarekRipa
New Member
5 0 0

Yes, I was thinking the same but when I tried this code it didn't work. Can you please check if the code is OK?

 

<script>
{% if request.locale.iso_code contains 'en' %}

<script>
{% if checkout.transactions[0].gateway == 'Bank Deposit' %}
Shopify.Checkout.OrderStatus.addContentBox('<h2>Pay Now</h2>',
'<p>EN INSTRUCTIONS</p>')
{% endif %}
</script>

 {% elsif request.locale.iso_code contains 'cs' %} 

<script>
{% if checkout.transactions[0].gateway == 'Bank Deposit' %}
Shopify.Checkout.OrderStatus.addContentBox('<h2>Pay Now</h2>',
'<p>CS INSTRUCTIONS</p>')
{% endif %}
</script>

{% endif %}
</script>