I have an application with a Django backend and AngularJS front-end. I use the angular -gettext plugin with Grunt to handle translations.
The thing is, sometimes I got dynamic strings from my backend through the API. For example, a MySQL error regarding foreign key constraints or duplicate key entries. How can I add these lines to a .pot file or a line without binding in general?
I tried to follow, but of course it cannot work:
angular.module('app').factory('HttpInterceptor', ['$q', '$injector', '$rootScope', '$cookieStore', 'gettext', function ($q, $injector, $rootScope, $cookieStore, gettext) {
responseError: function (rejection) {
gettext('static string');
gettext(rejection.data.error);
$rootScope.$emit('errorModal', rejection.data);
}
return $q.reject(rejection);
}
};
}]);
})();
One solution I could think of would be to write each dynamic line into a JSON object. Send this json to the server and from there write a static file containing these lines so gettext can extract them.
What are you offering?