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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742288759a4415802.html
评论列表(0条)