wiki
wiki copied to clipboard
Redirect to locale namespace by Accept-Language Header
Fixes/Implements: Redirect to user's browser preferred language
I'm planning to use wiki.js. I want to use this feature so I implement this feature.
TESTING
I've tested with the following commands (on zsh prompt). The development wiki.js instance has /home on english and japanese.
$ curl -H "Accept-Language: ja,en-US;q=0.9,en;q=0.8" 'http://localhost:3000/home'
Found. Redirecting to /ja/home%
$ curl -H "Accept-Language: en-US;q=0.9,en;q=0.8" 'http://localhost:3000/home'
Found. Redirecting to /en/home%
$ curl -H "Accept-Language: en-US" 'http://localhost:3000/home'
Found. Redirecting to /en/home%
$ curl -H "Accept-Language: en-US,ja;q=0.9" 'http://localhost:3000/home'
Found. Redirecting to /en/home%
$ curl -H "Accept-Language: fr" 'http://localhost:3000/home'
Found. Redirecting to /ja/home%