Dynamically change the checkout language

Aside from setting a default language for your checkout in Calendar Rates language settings, it is possible to dynamically change the language used for checkout, based on your users preference.

If you use a language selector with your theme, or a third party application, you can dynamically alter the language during the Calendar Rate checkout, by adding a hidden input to your cart form, containing the language code referenced in your themes locale files.

To do this, you will need to add in an input to your cart form. Please note, you should always make edits like this on an unpublished theme, in order to test before publishing:

1. Navigate to Admin -> Themes -> “Your theme” -> Actions -> Edit code:

2. Find your cart form. This is often located in a section file called “cart-template.liquid”

3. In your cart form template, find the opening form tag, and place this snippet directly beneath it:

{% comment %}
The below input controls the language used at checkout, and can be altered dynamically for any language in your locale files
{% endcomment %}

<input type="hidden" name="language_code" value="">

4. You can then detect the language from your language picker, and change the value of this input with javascript. This varies on a case by case basis, so some programming experience is required.

5. The value that you should populate the input with should match the name of the locale file in which you would like to use. For example, to use the french translations, populate “fr” in the inputs value:

Can't find the answer in our documentation?
Contact Support