How to detect/check current or default site language in liquid?

dbspez
Tourist
3 0 5

How to detect/check current or default site language in liquid?

What I'm trying to do is to display customer's first and last name in different order depending on the site language.

when the site default language is set to English , {{ customer.first_name }} {{ customer.last_name }}

when it is set to Korean, {{ customer.last_name }}{{ customer.first_name }}

I could not find any API objects from shopify doc/reference for site's default language.

 

{% if (WHAT SHOULD GO IN HERE?) == 'English?' %}

<h4 class="type-subheading type-subheading--1">{{ customer.first_name }} {{ customer.last_name }}</h4>

{% endif %}

{% if (WHAT SHOULD GO IN HERE?) == 'Korean?' %}

<h4 class="type-subheading type-subheading--1">{{ customer.last_name }}{{ customer.first_name }}</h4>

{% endif %}

 

0 Likes
tony5280
Shopify Partner
61 6 18

Seems liquid would be best, so try 

 

{{ request.path | slice: 1,2}}

 

A JS solution would be

var pathname = window.location.pathname;
var lang= pathname.split("/");
//lang[1] - this will have your langauge code

 

0 Likes
tony5280
Shopify Partner
61 6 18

If this was helpful at all, please consider marking this as the solution. If this didn't help, what results did you see?

0 Likes