Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

$translateProvider - Load JSON from file

$
0
0

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
$translate.use(language);

Thats my service at the moment:
angular.module('starter')

.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);
	};

});

Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>