[SOLVED] $translateProvider - Load JSON from file

Hi all!

I am using the $translateProvider an i like to load the Translations via $http.get from a file…

At the moment im using

var t9nObj = T9n;
for (var lang in t9nObj.t9n){

	$translateProvider.translations(lang, t9nObj.t9n[lang]);


In the T9n is my JSON object. The code on top is in my .config-Part of the app. Soo… How can i load the translations via $http.get in an Controller? Mayme something like this below?

$ionicPlatform.ready(function () {

$http.get(cordova.file.dataDirectory + thefiles.t9nFile)
.success(function (data) {

var t9nObj = data;
for (var lang in t9nObj.t9n){

$translateProvider.translations(lang, t9nObj.t9n[lang]);


}, function (error) {




Or any other ideas?

Many thanks for your reply!

I use in the config:

prefix: ‘locale-’,
suffix: ‘.json’

to load all translations, then:


to activate the correct language.

Looks like u use one file for each translation?

In my case are all translations in one file (cause we re updating the translation file on demand via a serail).

Probably you can do it using custom load service, here is an example: https://github.com/angular-translate/angular-translate/wiki/Asynchronous-loading

Hi @fabioferrero!

Thanks for your good idea. I’m using only one file for all translation cause i’m update the language on demand at changes.

My json-File:
var t9N = {"serial":1453205597,"language":{"de":"LANGUAGE.1","en":"LANGUAGE.2"},"t9n":{"de":{"APP.BUTTON.NEXT":"Next","APP.BUTTON.BACK":"Back", ......

How can i “parse” my file to use it later with

Thats my service at the moment:

.factory('languageService', function ($http, $q) {

	return function (options) {

		var deferred = $q.defer();

		$http.get(cordova.file.dataDirectory + files.t9nFile).success(
			function (data) {

				var data = data.language;

			}, function (error) {

		var data = {
			'TEXT': 'Fooooo'
		return deferred.resolve(data);
		// or
		return deferred.reject(options.key);


Hi all!

Found a solution for me, thanks.