Comments (8)
Seems like #48 could be related.
Given that the question about the bindings came up, I started reading the README a bit more closely. In the end, adding the following code to my application took care of the issue:
app.use( function( req, res, next ) {
// express helper for natively supported engines
res.locals.__i = res.__i = function() {
return i18n.__.apply( req, arguments );
};
res.locals.__n = res.__n = function() {
return i18n.__n.apply( req, arguments );
};
next();
} );
Then I could also remove this obsolete piece of code:
app.locals( {
__i: i18n.__,
__n: i18n.__n
} );
And now it's working with the latest and greatest :) Feel free to close if I didn't miss anything.
from i18n-node.
ok fine :)
you might even omit that custom setup inside app.use
if you start using __()
instead of __i()
. Please review https://gist.github.com/mashpie/5124626 for details. I'd also like to add a jade example, so don't hesitate sharing any hints.
Thanks!
from i18n-node.
I remember reading that __()
doesn't work because jade uses an internal variable named __
which conflicts with this default name. I thought that this is what makes the case with jade special. But I haven't really checked if that still holds true.
from i18n-node.
According this issue: pugjs/pug#403
Jade not use __ anymore. Currently version express + jade + i18n works fine for me
from i18n-node.
correct.. left this ticket open until setup another example...
from i18n-node.
I just created a example here:
[email protected] + [email protected] + [email protected]
https://gist.github.com/hankwang/5994144
from i18n-node.
@HankWang haha! same idea over here, see https://github.com/mashpie/i18n-node/tree/master/examples/express-jade - so I'll link your gist in README, ok?
from i18n-node.
@mashpie sure :)
from i18n-node.
Related Issues (20)
- Element with id="locale" and global registration crashes HOT 4
- how to pass a default translation if a phrase isnt existed in the en.json file HOT 3
- Locales are case sensitive HOT 3
- __h has strange behavior when he doesn't have the key HOT 1
- [Discussion] Contrast reports path traversal vulnerability HOT 4
- [Discussion] Allow a parser option to customize storage format HOT 2
- Maximum call stack size exceeded with some settings HOT 4
- Get string from locale file without substitution HOT 4
- passing a zero number value (0) incorrectly returns the full json string, brackets and all, without injecting the replacement value HOT 3
- When i18n is packaged into exe cannot be used, i18n directory cannot find the files under the directory path. HOT 3
- yml parser TypeScript and locale issues
- [Bug] translation API is returning `undefined` when provided locale is `undefined` or `null`
- There are no 0.15.1 release and tag.
- There are no 0.15.1 release and tag. HOT 1
- i18n ignores en.json language file HOT 1
- Error: Cannot find module Cyclic.sh sever HOT 1
- Problems with local files HOT 3
- ES Modules HOT 9
- feature request: support plurals with specific numbers HOT 5
- Readonly environment HOT 2
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 i18n-node.