jquery.i18n
jquery.i18n copied to clipboard
JSON Object in Object
Friends library has support for objects inside objects because my script is criticizing: Uncaught TypeError: message.indexOf is not a function
example json:
{
"en": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n",
"appname-header-introduction": "Introduction",
"example": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n"
},
"appname-about": "About this application",
"appname-footer": "Footer text"
},
"ml": {
"appname-title": "เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตโ เดเดฆเดพเดนเดฐเดฃเด",
"appname-sub-title": "jquery.i18n เดเดชเดฏเตเดเดฟเดเตเดเตเดณเตเดณ เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตโ เดเดฆเดพเดนเดฐเดฃเด",
"appname-header-introduction": "เดเดฎเตเดเด",
"example": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n"
},
"appname-about": "เด เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตเดชเตเดชเดฑเตเดฑเดฟ",
"appname-footer": "เด
เดเดฟเดเตเดเตเดฑเดฟเดชเตเดชเตเต"
}
}
}
```
Same issue !
Me to... How can i call an object in object, like content.title
The error message "Uncaught TypeError: message.indexOf is not a function" is thrown when you try to use the indexOf() method on a variable that is not a string. It seems like you are trying to use this method on an object. The Friends library does support objects inside objects. You can access the nested object by using dot notation or bracket notation. Here's an example of how you can access the nested object:
var json = {
"en": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n",
"appname-header-introduction": "Introduction",
"example": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n"
},
"appname-about": "About this application",
"appname-footer": "Footer text"
},
"ml": {
"appname-title": "เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตโ เดเดฆเดพเดนเดฐเดฃเด",
"appname-sub-title": "jquery.i18n เดเดชเดฏเตเดเดฟเดเตเดเตเดณเตเดณ เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตโ เดเดฆเดพเดนเดฐเดฃเด",
"appname-header-introduction": "เดเดฎเตเดเด",
"example": {
"appname-title": "Example Application",
"appname-sub-title": "An example application with jquery.i18n"
},
"appname-about": "เด เด
เดชเตเดฒเดฟเดเตเดเตเดทเดจเตเดชเตเดชเดฑเตเดฑเดฟ",
"appname-footer": "เด
เดเดฟเดเตเดเตเดฑเดฟเดชเตเดชเตเต"
}
};
console.log(json.en.example["appname-title"]); // Output: Example Application
console.log(json.ml["appname-footer"]); // Output: เด
เดเดฟเดเตเดเตเดฑเดฟเดชเตเดชเตเต