Skip to content

Commit

Permalink
nodejs.org: falling back to english when page hasn't been translated.
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipj committed Apr 25, 2016
1 parent 4030c77 commit ebf0e0b
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion setup/www/resources/config/nodejs.org
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ server {
default_type text/plain;
index index.html;

error_page 404 @localized_404;

if ($host ~* ^www\.){
rewrite ^(.*)$ http://nodejs.org$1;
}

location / {
try_files $uri $uri/ @english_fallback;

location ~ \.json$ {
add_header access-control-allow-origin *;
}
Expand All @@ -59,6 +63,19 @@ server {
add_header access-control-allow-origin *;
}
}

# instead of serving a 404 page when a page hasn't been translated
location @english_fallback {
if ($uri ~* ^/(it|ko)/) {
set $lang $1;
}
rewrite ^/(it|ko)/(.*)$ /en/$2;
}

# serve a localized 404 page if we've got $lang set from @english_fallback
location @localized_404 {
try_files /$lang/404.html /en/404.html;
}
}

server {
Expand Down Expand Up @@ -188,7 +205,7 @@ server {
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

error_page 404 /en/404.html;
error_page 404 @localized_404;

if ($host ~* ^www\.) {
rewrite ^(.*)$ https://nodejs.org$1;
Expand All @@ -215,11 +232,26 @@ server {
location / {
rewrite ^/$ /en/ redirect;

try_files $uri $uri/ @english_fallback;

location ~ \.json$ {
add_header access-control-allow-origin *;
}
}

# instead of serving a 404 page when a page hasn't been translated
location @english_fallback {
if ($uri ~* ^/(it|ko)/) {
set $lang $1;
}
rewrite ^/(it|ko)/(.*)$ /en/$2;
}

# serve a localized 404 page if we've got $lang set from @english_fallback
location @localized_404 {
try_files /$lang/404.html /en/404.html;
}

location /download {
alias /home/dist/nodejs;
autoindex on;
Expand Down

0 comments on commit ebf0e0b

Please sign in to comment.