The `customer_locale` property. How is it set?

Solved
tamarah
New Member
3 0 0

Hi there,

The `customer_locale` property. How is it set?

I've looked at this questions on the forum: https://community.shopify.com/c/Shopify-APIs-SDKs/Checkout-Customer-Locale/td-p/448845

I also thought it was set by the locale of the store but there is no confirmation nowhere also not in the docs and this guy on the forum even had another experience with it.

So how is this property set? Is it true that it's set by the locale of the store? So that a store with only 1 locale (no translation apps) will always deliver the same value in customer locale? regardless of the location of the shipping address?

I hope you can help me with this.. All help is appreciated!

Accepted Solution (1)

Accepted Solutions
marcd
Excursionist
14 1 3

This is an accepted solution.

{% case customer_locale %}
        {% when 'en' %}
            engelse text
        {% when 'de' %}
            duitse text
        {% else %}
            nederlandse TEXT
{% endcase %}

Works 

View solution in original post

Replies 4 (4)
marcd
Excursionist
14 1 3

Hi @tamarah,

I'm in the same boot as u. So I'm going to follow this topic.

My situation:

Buy Button channel that uses html lang attribute to change the checkout url to include the local paramater.

var theLanguage = $('html').attr("lang");
console.log(theLanguage);
if(theLanguage == "nl-NL"){
  var localCheckout = '&locale=nl';

and then on the cart property:

"events": {
          afterInit: (cart) => {
            cart.onCheckout = () => {
              const checkoutUrl = cart.model.webUrl + localCheckout;
              // we dynamically change the checkout function.
              cart.checkout.open(checkoutUrl);
            };
          },

In the backend I can see the local attribute:

customerinfo.png

 

I'm just not sure how I can use this Taal: Engels (Language: English) attribute in the notifications to customise these. I tried 2 orders, 1 on local=en and 1 on local=de.

The default transactional emails arrived perfectly in different languages. I'm just not sure to use the attribute to adjust the email templates. 

Should be something like:

    {% case customer.lang %}
        {% when 'fr' %}
            FRENCH TEXT
        {% when 'es' %}
            SPANISH TEXT
        {% when 'pt' %}
            PORTUGUESE TEXT
        {% else %}
            ENGLISH TEXT
     {% endcase %}

So I hope that in following this topic we both can find a solution.

marcd
Excursionist
14 1 3

This is an accepted solution.

{% case customer_locale %}
        {% when 'en' %}
            engelse text
        {% when 'de' %}
            duitse text
        {% else %}
            nederlandse TEXT
{% endcase %}

Works 

SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @tamarah 

From an earlier answer

In doing some testing it looks like the customer_locale field is set by the language that a shop's theme is set to - so if they're using Shopify's theme translations/languages this should be set on any orders that go through the storefront.

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

CandJ
Tourist
13 0 1

Hi!

We are looking for a way to display the customers language in the Shopify backend. The 'Taal: Engels' is not displayed in our Shopify backend.

Do you remember how you got this displayed?

Dankjewel!