0

In my angularJs application, with django backend, I'm using angular-translate to handle multilingual work. It is working fine for AngularJs (html and controller) files, but for login file, that is rendering as template from django, it is giving exception

TemplateSyntaxError at /login

Invalid filter: 'translate'

Here is exception detail;

First Exception

This is html where I'm trying to use translate

Login Form HTML

Username key is defined in related language json file, that is referenced in configuration file of loginApp like this;

angular.module('loginApp')
.factory("asyncLoader", asyncLoader)
.config(config);

config.$inject = ['$translateProvider'];
function config($translateProvider)
{
 $translateProvider.fallbackLanguage('en');
 $translateProvider.useLoader('asyncLoader');
}

asyncLoader.$inject = ['$q', '$timeout', '$http'];
function asyncLoader($q, $timeout, $http)
{
return function(options){
    
    var defferred = $q.defer(), translations;
    var resturl = "static/loginApp/lang" + options.key + ".json";
    
    $http.get(resturl, {cache:false}).success(function(translations) {
        defferred.resolve(translations);
        
    }).error(function(translations){
        defferred.reject(translations);
        
    });
    
    $timeout(function (){
        defferred.resolve(translations);
    },2000);
    
    return defferred.promise;
};
}

This whole setting is working file with login controller file, but when I use it in html, it throws template rendering error.

this is how I'm rendering login.html' as template in my django app views.py`

def LoginTemplate(request):
return HttpResponse(get_template('login.html').render())

I don't know what I'm missing, Any kind of help will be appreciated.

Community
  • 1
  • 1
Naila Akbar
  • 3,033
  • 4
  • 34
  • 76

0 Answers0