Skip to content

Commit

Permalink
Merge pull request #1065 from ORCID/feature/nginx_add_language_suppor…
Browse files Browse the repository at this point in the history
…t_for_angular_ui_app

Feature/nginx add language support for angular UI app
  • Loading branch information
bobcaprice authored Dec 18, 2023
2 parents 2fe7fb3 + 5d646ba commit b5a2f97
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
28 changes: 17 additions & 11 deletions ui/container-files/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ server {

#access_log /var/log/nginx/host.access.log main;

# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "fr";
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
rewrite ^/ui/(.*) /$1 break;
try_files $uri $uri/ /index.html;
}

# JT. Uncomment the error_page directive below to use the orcid 404 error page in /404
#error_page 404 ../404;
# Redirect requests for "/ui/(.*)" to Angular application in the preferred language of the browser
rewrite ^/ui/(.*) /$accept_language/$1 break;

# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# Everything under the Angular application is always redirected to Angular in the correct language
# For reference on multi language support see: https://angular.io/guide/i18n-common-deploy#configure-a-server
location ~ ^/(cs|de|es|fr|it|ja|ko|pt|ru|ui|zh-CN|zh-TW) {
try_files $uri $uri/ /$1/index.html?$args;
}

# Can use this line below instead of the location stanza above
# Everything under the Angular application is always redirected to Angular in the correct language
#try_files $uri $uri/ /$accept_language/index.html?$args;
}

}

22 changes: 19 additions & 3 deletions ui/container-files/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
Expand All @@ -27,5 +25,23 @@ http {

#gzip on;

# Browser preferred language detection (does NOT require AcceptLanguageModule)
# For reference on multi language support see: https://angular.io/guide/i18n-common-deploy#configure-a-server
map $http_accept_language $accept_language {
~*^cs cs;
~*^de de;
~*^es es;
~*^fr fr;
~*^it it;
~*^ja ja;
~*^ko ko;
~*^pt pt;
~*^ru ru;
~*^ui ui;
~*^zh-CN zh-CN;
~*^zh-TW zh-TW;
}

include /etc/nginx/conf.d/*.conf;
}

}

0 comments on commit b5a2f97

Please sign in to comment.