Locales / Multi-Lang Content

Zesty.io Supports multiple locales/languages for each content item

When a Zesty.io Content Instance is created, it uses English as the default language. It is possible to add more languages to a Zesty.io Content Instance. Multi-lang content is premium feature of Zesty.io, reach out to your account manager to learn more.

Adding Multi-lang Content

The API must be used to add additional locales/languages to a Content Instance.

Note: adding a language makes that language's relative pages available in preview, to have a added language be accessible to the live production domain, you need to activate the language

API Reference: Adding a Language

What happens when a new language is added?

When a new language is created, Zesty.io's API will automate a process to duplicate all content into a language specific version of that content. The default language is content is copied into the new language version (it is not automatically translated). For example, if you had an english about page (url /about/), and added Spanish with the locale of Mexico, a new content items would be created with the URL /es-mx/about/ and the content item would be pre-filled with the default language content. These means you would have a Spanish placeholder content item with english words in it to start. All copied new language pages start at version one (with default language content pre-filler) and have their own version control.

The default language can only be chosen at the creation of a content instance. Talk to a Zesty.io support tech for help doing this.

How to Activate a language

Languages are added "non-active" meaning they are not accessible via the published website. It is setup that way so developers can add a language and prepare all the content by updates and publishing without affecting the live website. Once a language is ready to go live, it must be activated.

API Reference: Activating a Language

How Does Web Engine Handle Multi-lang/Multi-Locale Content

When Web Engine detects there are multiple languages on a Content Instance it will add specific code that is read by browsers, screen readers, and search engines to direct users to different languages/locales of the content it serves.

For example purposes, let's use the domain www.acme.com, and assume it has two languages, English (en-us) and Spanish (es-mx).

Server Headers Appended for Locale/Multi-lang, per
MDN Specs

// Server headers served when accessing https://www.acme.com/about/

Content-Language: en-us

HTML Appended for Locale/Multi-lang, per
Google Specs

// Head and HTML additions on page https://www.acme.com/about

<html lang="en-us">
<head>
  <title>About Acme, Inc</title>
  <link rel="alternate" hreflang="en-us"
        href="https://www.acme.com/about/" />
  <link rel="alternate" hreflang="es-mx"
        href="https://www.acme.com/es-mx/about/" />
  <link rel="alternate" hreflang="x-default"
        href="https://www.acme.com/about/" />
</head>

XML Sitemap

Auto-generated sitemap gets additional language qualifiers and pointers.

//Served at https://www.acme.com/sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>http://www.example.com/english/page.html</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>

Accessing Multi-Lang Locales with Parsley

Accessing the current language using Parsley is done by calling

  • {{instance.current_lang.code}}
  • {{instance.current_lang.id}}
  • {{instance.current_lang.name}}
  <!-- to access them globally with javascript, add this to the top of the loader file-->
  <script>
  CURRENT_LANG_ID = '{{instance.current_lang.id}}'; // 1
  CURRENT_LANG_NAME = '{{instance.current_lang.name)}}'; // English (United States) 
  CURRENT_LANG_CODE = '{{instance.current_lang.code)}}'; // en-us
  </script> 
  <!-- this method is useful to array filter out locale content when using headless endpoint with client side javascript-->

Parsley can be used to iterate through available languages. {{each langs as lang}} give you access to

  • {{lang.code}} string e.g. en-US , es-MX
  • {{lang.default}} Boolean 1 or 0, 1 is true
  • {{lang.name}} string e.g. English (United States), Spanish (Mexico)

locale -sm

// Parsley example usage for each looping through langs

{{each langs as lang}}
	{{if {lang.default} == 1}}
	{{$path = / }}
	{{else}}
	{{$path = /{lang.code}/ }}
	{{end-if}}
	<a class="navbar-item" href="{{$path}}">
		<span class="icon mr-2">
			<img src="https://4q6k83l9.media.zestyio.com/{{lang.code}}.png?width=32" alt="{{lang.name}} flag"/>
		</span>
		<span>
			{{lang.name}}
		</span>
	</a>
{{end-each}}

List of Languages Zesty.io Supports

Each language has an associated code, that code is used in the API to create a new language for a Content Instance.

CodeLanguage
afAfrikaans
af-ZAAfrikaans (South Africa)
arArabic
ar-AEArabic (U.A.E.)
ar-BHArabic (Bahrain)
ar-DZArabic (Algeria)
ar-EGArabic (Egypt)
ar-IQArabic (Iraq)
ar-JOArabic (Jordan)
ar-KWArabic (Kuwait)
ar-LBArabic (Lebanon)
ar-LYArabic (Libya)
ar-MAArabic (Morocco)
ar-OMArabic (Oman)
ar-QAArabic (Qatar)
ar-SAArabic (Saudi Arabia)
ar-SYArabic (Syria)
ar-TNArabic (Tunisia)
ar-YEArabic (Yemen)
azAzeri (Latin)
az-AZAzeri (Azerbaijan)
beBelarusian
be-BYBelarusian (Belarus)
bgBulgarian
bg-BGBulgarian (Bulgaria)
bs-BABosnian (Bosnia and Herzegovina)
caCatalan
ca-ESCatalan (Spain)
csCzech
cs-CZCzech (Czech Republic)
cyWelsh
cy-GBWelsh (United Kingdom)
daDanish
da-DKDanish (Denmark)
deGerman
de-ATGerman (Austria)
de-CHGerman (Switzerland)
de-DEGerman (Germany)
de-LIGerman (Liechtenstein)
de-LUGerman (Luxembourg)
dvDivehi
dv-MVDivehi (Maldives)
elGreek
el-GRGreek (Greece)
enEnglish
en-AUEnglish (Australia)
en-BZEnglish (Belize)
en-CAEnglish (Canada)
en-CBEnglish (Caribbean)
en-GBEnglish (United Kingdom)
en-IEEnglish (Ireland)
en-JMEnglish (Jamaica)
en-NZEnglish (New Zealand)
en-PHEnglish (Republic of the Philippines)
en-TTEnglish (Trinidad and Tobago)
en-USEnglish (United States)
en-ZAEnglish (South Africa)
en-ZWEnglish (Zimbabwe)
eoEsperanto
esSpanish
es-ARSpanish (Argentina)
es-BOSpanish (Bolivia)
es-CLSpanish (Chile)
es-COSpanish (Colombia)
es-CRSpanish (Costa Rica)
es-DOSpanish (Dominican Republic)
es-ECSpanish (Ecuador)
es-ESSpanish (Spain)
es-GTSpanish (Guatemala)
es-HNSpanish (Honduras)
es-MXSpanish (Mexico)
es-NISpanish (Nicaragua)
es-PASpanish (Panama)
es-PESpanish (Peru)
es-PRSpanish (Puerto Rico)
es-PYSpanish (Paraguay)
es-SVSpanish (El Salvador)
es-UYSpanish (Uruguay)
es-VESpanish (Venezuela)
etEstonian
et-EEEstonian (Estonia)
euBasque
eu-ESBasque (Spain)
faFarsi
fa-IRFarsi (Iran)
fiFinnish
fi-FIFinnish (Finland)
foFaroese
fo-FOFaroese (Faroe Islands)
frFrench
fr-BEFrench (Belgium)
fr-CAFrench (Canada)
fr-CHFrench (Switzerland)
fr-FRFrench (France)
fr-LUFrench (Luxembourg)
fr-MCFrench (Principality of Monaco)
glGalician
gl-ESGalician (Spain)
guGujarati
gu-INGujarati (India)
heHebrew
he-ILHebrew (Israel)
hiHindi
hi-INHindi (India)
hrCroatian
hr-BACroatian (Bosnia and Herzegovina)
hr-HRCroatian (Croatia)
huHungarian
hu-HUHungarian (Hungary)
hyArmenian
hy-AMArmenian (Armenia)
idIndonesian
id-IDIndonesian (Indonesia)
isIcelandic
is-ISIcelandic (Iceland)
itItalian
it-CHItalian (Switzerland)
it-ITItalian (Italy)
jaJapanese
ja-JPJapanese (Japan)
kaGeorgian
ka-GEGeorgian (Georgia)
kkKazakh
kk-KZKazakh (Kazakhstan)
knKannada
kn-INKannada (India)
koKorean
ko-KRKorean (Korea)
kokKonkani
kok-INKonkani (India)
kyKyrgyz
ky-KGKyrgyz (Kyrgyzstan)
ltLithuanian
lt-LTLithuanian (Lithuania)
lvLatvian
lv-LVLatvian (Latvia)
miMaori
mi-NZMaori (New Zealand)
mkFYRO Macedonian
mk-MKFYRO Macedonian (Former Yugoslav Republic of Macedonia)
mnMongolian
mn-MNMongolian (Mongolia)
mrMarathi
mr-INMarathi (India)
msMalay
ms-BNMalay (Brunei Darussalam)
ms-MYMalay (Malaysia)
mtMaltese
mt-MTMaltese (Malta)
nbNorwegian (Bokm?l)
nb-NONorwegian (Bokm?l) (Norway)
nlDutch
nl-BEDutch (Belgium)
nl-NLDutch (Netherlands)
nn-NONorwegian (Nynorsk) (Norway)
nsNorthern Sotho
ns-ZANorthern Sotho (South Africa)
paPunjabi
pa-INPunjabi (India)
plPolish
pl-PLPolish (Poland)
psPashto
ps-ARPashto (Afghanistan)
ptPortuguese
pt-BRPortuguese (Brazil)
pt-PTPortuguese (Portugal)
quQuechua
qu-BOQuechua (Bolivia)
qu-ECQuechua (Ecuador)
qu-PEQuechua (Peru)
roRomanian
ro-RORomanian (Romania)
ruRussian
ru-RURussian (Russia)
saSanskrit
sa-INSanskrit (India)
seSami (Northern)
se-FISami (Finland)
se-NOSami (Norway)
se-SESami (Sweden)
skSlovak
sk-SKSlovak (Slovakia)
slSlovenian
sl-SISlovenian (Slovenia)
sqAlbanian
sq-ALAlbanian (Albania)
sr-BASerbian (Bosnia and Herzegovina)
sr-SPSerbian (Serbia and Montenegro)
svSwedish
sv-FISwedish (Finland)
sv-SESwedish (Sweden)
swSwahili
sw-KESwahili (Kenya)
syrSyriac
syr-SYSyriac (Syria)
taTamil
ta-INTamil (India)
teTelugu
te-INTelugu (India)
thThai
th-THThai (Thailand)
tlTagalog
tl-PHTagalog (Philippines)
tnTswana
tn-ZATswana (South Africa)
trTurkish
tr-TRTurkish (Turkey)
ttTatar
tt-RUTatar (Russia)
tsTsonga
ukUkrainian
uk-UAUkrainian (Ukraine)
urUrdu
ur-PKUrdu (Islamic Republic of Pakistan)
uzUzbek (Latin)
uz-UZUzbek (Latin) (Uzbekistan)
viVietnamese
vi-VNVietnamese (Viet Nam)
xhXhosa
xh-ZAXhosa (South Africa)
zhChinese
zh-CNChinese (S)
zh-HKChinese (Hong Kong)
zh-MOChinese (Macau)
zh-SGChinese (Singapore)
zh-TWChinese (T)
zuZulu
zu-ZAZulu (South Africa)

See Google reference on localized versions