From this example, it explains the way to write nginx config to switch the language between DE and EN. using Modx as CMS. However, I have 3 languages which are EN/DA/TH. Please guide me to the right approach of writing nginx config to change between 3 languages. (Please note, EN is the default) The following is the nginx config that allows only 2 languages switching.
set $lang de;
# choose the language that appears first in the accept_language header
if ($http_accept_language ~* "(de|en)") {
set $lang $1;
}
location ~ ^/$ {
rewrite ^ $lang/ redirect;
}
location ~ ^/(de|en) {
# redirect favicon.ico and assets/* requests to site root
rewrite ^/(de|en)/(favicon.ico|assets.*)$ /$2 redirect;
# main Babel rewrite
rewrite ^/(de|en)/(.*)$ /?cultureKey=$1&q=$2 break;
# MODX rewrite
try_files $uri $uri/ @modx-rewrite;
}
location / {
try_files $uri $uri/ @modx-rewrite;
}