Comments (11)
you can use https://github.com/i18next/i18next-node/blob/master/lib/i18next.js#L314
in combination with the ensureSupportedLanguage Middleware on line 325
from i18next-node.
This doesn't fix everything I think.
I now added
ensureLngSupport: true
to the configuration.
Basically what it does now is:
/en/team
(200) 👍
/en/team/xxx
(404) 👍
/
(200) 👍
/xxx
(200, should be 404) 👎
/en/
(404, should be 200) 👎
Hope this isn't too hard to understand.
from i18next-node.
i18n.addRoute('/:lng/'
will result in /en
route not /en/
why /xxx
is allowed idk.
from i18next-node.
might need to add some more test cases here: https://github.com/i18next/i18next-node/blob/master/test/i18next.server.spec.js#L40 but on holiday right now...so not sure i get to it right now.
from i18next-node.
Hm. /de
and /de/
do render, but in English, not German. Thats why I think that something is buggy because after the /
everything is allowed and it renders over the Controller.home
.
from i18next-node.
not sure...https://github.com/i18next/i18next-node/blob/master/test/i18next.server.spec.js#L70 tests this and tests are ok...but might be i miss something in the test cases.
from i18next-node.
I tested a bit more, and broke it down to one line:
with
ensureLngSupport: true
the code which is causing this is:
i18n.addRoute('/:lng/', Config.get('languages'), app, 'get', Controllers.home);
This is also true when you use it without the slash at the end
(/:lng
)
from i18next-node.
as far i know that's regular behaviour in express. /something/
allows /something
. you might try a regex route like /:lng/*
from i18next-node.
Hm. I just also just discovered that you can put anything in /:lng/
( Like /isaduh/team/
) and it will also render in English.
from i18next-node.
anything passed to /:lng/
will be taken as param. So some invalid language there will fallback to your fallback language. the /:lng
will not be translated or replaced as all params be kept as params for express -> /:lng will be needed to grab the language.
might optimize that after upcoming version v2 of i18next.
from i18next-node.
upcoming v2: http://i18next.github.io/i18next.com/
i18next-node will be replaced by https://github.com/i18next/i18next-express-middleware
PRs welcome
from i18next-node.
Related Issues (20)
- i18next multiple json packages HOT 2
- Multiple handler on addRoute function HOT 3
- remoteSync don't write empty resource to store if remote is unavaiable
- Semvar violations HOT 2
- How to use variables with handlebars HOT 10
- remoteSync: saveMissing use resSetPath, not resPostPath HOT 3
- document webtranslate path options HOT 1
- document t helper
- Cannot read property '_translationTable' of undefined - i18next on OSX and docker HOT 2
- MongoDB backend fails to initialize HOT 6
- How do I create custom detectLanguage function\middleware? HOT 2
- Error when trying to pluralise HOT 4
- Dinamically add new namespace? HOT 2
- Question: what is the best practice for i18next-node locales? HOT 9
- [same project?] Some pages down HOT 2
- README clarification HOT 1
- t is not a function HOT 8
- saveMissingTo: "all" does not save missing translation in all languages files
- Dynamic update app language in React Native using i18next HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18next-node.