admin管理员组文章数量:1332873
THE SITUATION:
I am using angular-translate for my app.
Everything was working perfectly. But i just needed to move the translations into static json files.
I have followed all the instructions but is not working.
THE CODE (BEFORE):
$translateProvider.translations('en', {
"WELCOME": "Wele",
});
$translateProvider.translations("tr", {
"WELCOME": "Hoşgeldiniz",
});
$translateProvider.translations("it", {
"WELCOME": "Benvenuto",
});
THE CODE (NOW):
$translateProvider.useStaticFilesLoader({
prefix: '/translations/',
suffix: '.json'
});
JSON FILES:
path:
www/translations/en.json
www/translations/it.json
www/translations/tr.json
Example:
{
"WELCOME": "Benvenuto",
}
ERROR:
SyntaxError: Unexpected token } in JSON at position 4160
at Object.parse (native)
THE QUESTION:
How can i load the translations from static json using angular-translate?
What can be wrong in my case?
Thank you!
THE SITUATION:
I am using angular-translate for my app.
Everything was working perfectly. But i just needed to move the translations into static json files.
I have followed all the instructions but is not working.
THE CODE (BEFORE):
$translateProvider.translations('en', {
"WELCOME": "Wele",
});
$translateProvider.translations("tr", {
"WELCOME": "Hoşgeldiniz",
});
$translateProvider.translations("it", {
"WELCOME": "Benvenuto",
});
THE CODE (NOW):
$translateProvider.useStaticFilesLoader({
prefix: '/translations/',
suffix: '.json'
});
JSON FILES:
path:
www/translations/en.json
www/translations/it.json
www/translations/tr.json
Example:
{
"WELCOME": "Benvenuto",
}
ERROR:
SyntaxError: Unexpected token } in JSON at position 4160
at Object.parse (native)
THE QUESTION:
How can i load the translations from static json using angular-translate?
What can be wrong in my case?
Thank you!
Share Improve this question edited Jun 10, 2016 at 14:07 FrancescoMussi asked Jun 10, 2016 at 13:54 FrancescoMussiFrancescoMussi 21.6k40 gold badges129 silver badges181 bronze badges 3-
Do you know which file triggers the error? If not try them one by one and look what is at position 4160. Should be a
}
too much – KRONWALLED Commented Jun 10, 2016 at 14:13 - That's the point. I cannot debug it. In the console it just point to: at fromJson (localhost:8100/lib/ionic/js/ionic.bundle.js:9892:14) – FrancescoMussi Commented Jun 10, 2016 at 14:14
- Open the json file, copy everything into chrome console and look at the errors, change file accordingly, rinse and repeat – KRONWALLED Commented Jun 10, 2016 at 14:17
1 Answer
Reset to default 6Removing char ',' at the end of key definition in your json. It make json parser try to read next char '}' as new key and error raised
本文标签: javascriptangulartranslate How to load static json filesStack Overflow
版权声明:本文标题:javascript - angular-translate: How to load static json files? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742288758a2447409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论