I have a nested json structure like this
{
"module1": {
"component1": "text1",
"component2": "text2"
}
}
So inside my code I am using {"module1.component1" | translate}
which never get resolved whereas if I do
{
"component1": "text1",
"component2": "text2"
}
{"component1" | translate}
works . Is there a way to resolve nested JSON data using useStaticFilesLoader
edit 1: here is my useStaticFilesLoader config looks like :
$translateProvider.useStaticFilesLoader({
prefix: './langfiles/',
suffix: '.json'
});
$translate.use(lang);//lang is derived from header
langfiles contains : en_US.json etc
Check out this post: Accessing nested JSON objects and see if that helps. Their JSFiddle show how it can be done: http://jsfiddle.net/z1uLjg89/
A possible work around is to flatten your json file.
Fastest way to flatten / un-flatten nested JSON objects or Convert complex JavaScript object to dot notation object
This fiddle shows you how what it will look like: http://fiddle.jshell.net/blowsie/S2hsS/show/light/