Skip to content

Instantly share code, notes, and snippets.

@pragex
Created August 9, 2018 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pragex/9bce5526c4531898c2776f8926d6d6aa to your computer and use it in GitHub Desktop.
Save pragex/9bce5526c4531898c2776f8926d6d6aa to your computer and use it in GitHub Desktop.
server {
listen 80;
[...]
location / {
[...]
}
# **** ADD THIS SECTION TO YOUR FILE ****
# Add the support for french "fr" and english "en" on Erpnext Website section
set $test "";
set $language $cookie_language;
#Exclude URL begin by:
if ( $request_uri !~* ^/(fr/|en/|socket\.io/|desk[^\w-]?|\?|assets/|private/|public/) ) {
set $test "${request_method}/${language}";
}
#Exclude file request
if ( $request_uri ~* "^[^?&=:]+(\.js|\.woff.?|\.\w{3}|\.\w{4})$" ) {
set $test "";
}
if ( $test ~* ^GET/(fr|en)$ ) {
return 302 $scheme://$host/$language$request_uri;
}
location /en/ {
set $language "en";
rewrite ^/en(.*)$ $1?_lang=en;
}
location /fr/ {
set $language "fr";
rewrite ^/fr(.*)$ $1?_lang=fr-CA;
}
add_header Set-Cookie "language=$language;Path=/";
# **** END SECTION ****
location @webserver {
[...]
}
[...]
@Mar87iam
Copy link

Mar87iam commented Feb 6, 2021

can u explain a little bit how to do this
as i need my website homepage bilingual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment