Accessing Multi-language in Ajax files and Parsley
Accessing Multi-language in Ajax files via GET query parameter, and using parsley call for the current language
Accessing Multi-language in Ajax files
For AJAX "files" (served as /ajax/example
), the language can be specified via a GET query parameter.
Example: /ajax/example?lang=fr-ca
.
A helpful tip for doing this automatically in ajax calls is to use the parsley call for the current language:
{{ site.current_lang }}
.
Accessing Multi-language in Parsley
Accessing content in multiple languages is very simple in Parsley.
You simply access the properties of the page in the same way (page.title
for example). Content will automatically be loaded in the correct language based on the current visitors language.
HTML changes based on language
To make a html change specific for the current visitor's language code.
{{ if {site.current_lang} == 'es' }}
Hola!
{{ else }}
Hello!
{{ end-if }}
Updated 9 months ago