Skip to content

Commit

Permalink
Add i18n error pages.
Browse files Browse the repository at this point in the history
The previous attempt at error pages didn't entirely work. Paths were
wrong, and more importantly all languages would get english error pages
with english nav. This wasn't great, but by making the nginx
configuration a bit more verbose we can redirect users to 404 pages in
their language.

The `:orphan:` tags suppress the TOC warnings while still letting the
pages be built.
  • Loading branch information
markstory committed Jul 25, 2016
1 parent 7b78e2f commit 49997d7
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 5 deletions.
1 change: 0 additions & 1 deletion config/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
# directories to ignore when looking for source files.
exclude_patterns = [
'themes',
'404.rst'
]

# The reST default role (used for this markup: `text`) to
Expand Down
2 changes: 2 additions & 0 deletions en/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down
2 changes: 2 additions & 0 deletions es/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down
2 changes: 2 additions & 0 deletions fr/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down
2 changes: 2 additions & 0 deletions ja/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down
32 changes: 28 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,34 @@ server {
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;

# Error pages not publically exposed
error_page 404 /404.html;
location = /404.html {
# Error handling
# error_page 404 /3.0/en/404.html;

error_page 404 @error_page;
location @error_page {
root /var/www/html;
internal;
set $error404 /3.0/en/404.html;
if ($request_filename ~ "/3.0/fr") {
set $error404 /3.0/fr/404.html;
}
if ($request_filename ~ "/3.0/es") {
set $error404 /3.0/es/404.html;
}
if ($request_filename ~ "/3.0/fr") {
set $error404 /3.0/fr/404.html;
}
if ($request_filename ~ "/3.0/ja") {
set $error404 /3.0/ja/404.html;
}
if ($request_filename ~ "/3.0/pt") {
set $error404 /3.0/pt/404.html;
}
if ($request_filename ~ "/3.0/tr") {
set $error404 /3.0/tr/404.html;
}
if ($request_filename ~ "/3.0/zh") {
set $error404 /3.0/zh/404.html;
}
rewrite ^(.*)$ $error404 break;
}
}
2 changes: 2 additions & 0 deletions pt/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Página não encontrada
#####################

Expand Down
2 changes: 2 additions & 0 deletions tr/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down
2 changes: 2 additions & 0 deletions zh/404.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan: True

Not Found
#########

Expand Down

0 comments on commit 49997d7

Please sign in to comment.