Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'abc' of undefined #364

Open
bizeasy17 opened this issue Apr 24, 2018 · 0 comments
Open

Cannot read property 'abc' of undefined #364

bizeasy17 opened this issue Apr 24, 2018 · 0 comments

Comments

@bizeasy17
Copy link

bizeasy17 commented Apr 24, 2018

environment
nodejs 8.0
express 4
i18n-node 3.0
give the error "Cannot read property 'abc' of undefined" when define the text in .hbs template file

in index.js (middleware)
`var i18n_module = require('i18n-nodejs'),//2018-4-22 JH
....
// 2018-4-22 JH START
var config = {
"lang": "zh-cn",
"langFile": path.join(__dirname + "/../locales/locale.json")//relative path to index.js file of i18n-nodejs module
}
var i18n = new i18n_module(config.lang, config.langFile);

...
module.exports = function(app, db, callback) {
...
app.engine('hbs', hbs.express4({
handlebars: HandleBars,
defaultLayout: path.join(__dirname, '../views/layout/main.hbs'),
i18n: i18n,//2018-4-24 JH
partialsDir: [path.join(__dirname + '/../views/partials/'), path.join(__dirname + '/../views/subviews/reports')]
}));
app.set('view engine', 'hbs');
hbsHelpers.register(hbs.handlebars);
...`

in template
<h4 style="font-size: 24px; margin-top: 7px; font-weight: 300;color: #222;"> {{__ 'PrivacyPolicy'}} <a class="uk-modal-close uk-close no-ajaxy right" aria-label="Close"></a> </h4>

in .json locale file
{ "TruDesk i18n initialized.": { "ar": "مرحبا", "zh-cn": "TruDesk i18n 初始化成功." }, "PrivacyPolicy": { "zh-cn": "隐私政策", "en": "Privacy Policy" } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant