express-locale | Express middleware to determine locale | Internationalization library
kandi X-RAY | express-locale Summary
kandi X-RAY | express-locale Summary
Express middleware to determine locale
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a locale middleware
express-locale Key Features
express-locale Examples and Code Snippets
Community Discussions
Trending Discussions on express-locale
QUESTION
I'm trying to handle requests correctly to a localized angular app hosted on Firebase. The goal is to load the right app bundle depending on: 1) A cookie named locale
. 2) The accept-language
header. 3) Default to en-us
when others are unavailable.
When localizing angular apps with i18n, angular-cli generates bundles (versions of your app) for each language/locale present in angular.json
. Firebase serves your bundles as static content and it has serious security measurements disallowing path traversals.
I tried both setting rewrites and redirects in firebase.json
but there is no facilities to intercept the locale
cookie. Then, I used cloud functions to read the cookie, parse requests and return the right resource using express
, cookie-parser
and express-locale
.
1. Using hosting only
firebase.json
...ANSWER
Answered 2019-Dec-05 at 01:40For anyone facing the same problem, here is a naive solution using firebase functions:
functions/index.jsCommunity Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install express-locale
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page