我从这里使用角度翻译(http://pascalprecht.github.io/angular-translate/)并且它工作正常,但它打破了我的控制器的单元测试错误:
Unexpected request: GET scripts/i18n/locale-en.json
Run Code Online (Sandbox Code Playgroud)
我不明白为什么?
我使用自耕农和业力考验.
app.js:
'use strict';
(function() {
angular.module('wbApp', ['authService', 'authUserService', 'checkUserDirective', 'ui.bootstrap', 'pascalprecht.translate'])
.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/login.html',
controller: 'LoginCtrl',
access: {
isFree: true
}
})
.when('/main', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
access: {
isFree: false
}
})
.otherwise({
redirectTo: '/'
});
});
})();
Run Code Online (Sandbox Code Playgroud)
configTranslate.js:
'use strict';
(function() {
angular.module('wbApp')
.config(['$translateProvider',
function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'scripts/i18n/locale-',
suffix: '.json'
});
$translateProvider.preferredLanguage('en');
}]);
})();
Run Code Online (Sandbox Code Playgroud)
karma.conf.js:
files = [
...
'app/bower_components/angular-translate/angular-translate.js',
'app/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
...
]; …Run Code Online (Sandbox Code Playgroud)