This is cool! I’m also not great with liquid so only having to actually type the longer logic out once and then use the snippet makes me feel a lot more confident that I’ll have consistency in my messages.
Thanks for sharing!
Thank you for sharing Chloe! That’s super useful!
hey Chloe,
like your post! I was confronted with the fact that in some languages there are specifc ways to use formal as well infomal greetings. I created some liquid that solves this issue.
The last version is in German, because there is no such a version in the English language.
Formal - No Salutation (Gender neutral)
Hello {% if customer.first_name %}{% if customer.last_name %}{{customer.first_name}} {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}dear customer{% endif %},
Note: When translating "dear customer" can be changed to the local gender neutral expression, e.g. in German "lieb:r Kund:in".
Formal - Salutation (Fallback gender neutral)
Hello {% if customer.gender == "female" %}{% if customer.last_name %}Mrs. {{customer.last_name}}{% else %}dear customer{% endif %}{% elsif customer.gender == "male" %}{% if customer.last_name %}Mr. {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}{% if customer.first_name %}{% if customer.last_name %}{{customer.first_name}} {{customer.last_name}}{% else %}dear customer{% endif %}{% else %}dear customer{% endif %}{% endif %},
Note: When translating "dear customer" can be changed to the local gender neutral expression, e.g. in German "lieb:r Kund:in".
Note: The attribute "gender" can also be replaced by "salutation".
Informal - No Salutation (Gender neutral)
Hello {% if customer.first_name %}{{customer.first_name}}{% else %}there{% endif %},
Informal - Salutation (Fallback gender neutral)
Hallo {% if customer.gender == "female" %}{% if customer.first_name %}liebe {{customer.first_name}}{% else %}liebe Kundin{% endif %}{% elsif customer.gender == "male" %}{% if customer.first_name %}lieber {{customer.first_name}}{% else %}lieber Kunde{% endif %}{% elsif customer.first_name %}lieb:r {{customer.first_name}}{% else %}lieb:r Kund:in{% endif %},
Note: You can replace the German words with any other lnaguage. Here is an explanation of the words in English:
- Hallo = Hello
- liebe = dear (female)
- lieber = dear (male)
- Kundin = customer (female)
- Kunde = customer (male)
- liebe:r Kund:in = gender neutral version of “dear customer”