// Including ngTranslate
angular.module("ngTranslate", ["ng"]).config(["$provide", function (n) {
$TranslateProvider = function () {
var n, t = {};
this.translations = function (n, r) {
if (!n && !r) return t;
if (n && !r) {
if (angular.isString(n)) return t[n];
t = n
} else t[n] = r
}, this.uses = function (r) {
if (!r) return n;
if (!t[r]) throw Error("$translateProvider couldn't find translationTable for langKey: '" + r + "'");
n = r
}, this.$get = ["$interpolate", "$log", function (r, a) {
return $translate = function (e, i) {
var l = n ? t[n][e] : t[e];
return l ? r(l)(i) : (a.warn("Translation for " + e + " doesn't exist"), e)
}
}]
}, n.provider("$translate", $TranslateProvider)
}]), angular.module("ngTranslate").directive("translate", ["$filter", "$interpolate", function (n, t) {
var r = n("translate");
return {
restrict: "A",
scope: !0,
link: function (n, a, e) {
e.$observe("translate", function (r) {
n.translationId = angular.equals(r, "") ? t(a.text())(n.$parent) : r
}), e.$observe("values", function (t) {
n.interpolateParams = t
}), n.$watch("translationId + interpolateParams", function () {
a.html(r(n.translationId, n.interpolateParams))
})
}
}
}]), angular.module("ngTranslate").filter("translate", ["$parse", "$translate", function (n, t) {
return function (r, a) {
return angular.isObject(a) || (a = n(a)()), t(r, a)
}
}]);
// Configuring your module, asking for ngTranslate as dependency
var app = angular.module('myApp', ['ngTranslate']);
// Configuring $translateProvider
app.config(['$translateProvider', function ($translateProvider) {
// Simply register translation table as object hash
$translateProvider.translations('en', {
"SEARCH": {
"SEARCH": "Recherce",
"ABILITY": "Abilities",
"MANAGEMENT": "Management Competencies",
"PERSONAL": "Personal Suitability"
},
"ABILITIES": {
"TITLE": "Test Title here",
"ADVISORY": {
"TITLE": "Advisory Skills",
"QUESTIONS": [{
"TYPE": "A",
"LEVEL": "45",
"DESCRIPTION": "Can you tell me how awesome you are"
}, {
"TYPE": "B",
"LEVEL": "100",
"DESCRIPTION": "Tell me about your wicked project"
}]
}
},
"HEADLINE": "Oh No!",
"SUB_HEADLINE": "Looks like you are not amazing"
});
var list = $translateProvider.translations('en');
console.log(list);
var getTitle = list.HEADLINE;
var getSearch = list.SEARCH.ABILITY;
console.log(getSearch);
console.log(getTitle);
}]);
<div ng-app="myApp"></div>