在以下文件中,我希望它显示翻译“这是一个标题”,但它没有显示任何内容。
我需要更改什么,以便此代码显示翻译“这是标题”?
<html ng-app="mainApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bower-angular-translate/2.5.2/angular-translate.min.js"></script>
</head>
<body ng-controller="mainController">
<div>[{{message}}]</div>
<div>[{{HEADLINE| translate}}]</div>
<script>
var mainApp = angular.module('mainApp', ['pascalprecht.translate']);
mainApp.config(function ($translateProvider) {
$translateProvider.translations('en', {
HEADLINE: 'This is the headline',
INTRO: 'This is the intro'
}).translations('de', {
HEADLINE: 'Dies ist die Kopfzeile',
INTRO: 'Dies ist die Einführung'
});
$translateProvider.preferredLanguage('en');
});
mainApp.controller('mainController', function ($scope, $translate) {
$scope.message = 'testing';
});
</script>
</body>
</html>