我正在尝试使用 AngularJS 翻译。我遇到的问题是我得到Unknown provider: $$cookieReaderProvider <- $$cookieReader <- $cookies <- $cookieStore <- $translateCookieStorage <- $translate <- $cookies
尝试使用时出错$translateProvider.useCookieStorage();
我已经注射了ngCookies
作为我的应用程序中的依赖项:
var nfqApp = angular.module('myApp', ['postServices', 'angularFileUpload', 'ngSanitize', 'ui.date',
'bootstrapLightbox', 'profileServices', 'ngRoute', 'angularMoment', 'pascalprecht.translate', 'ngCookies']);
我还按以下顺序包含了以下与翻译和 cookie 相关的文件:
- 角度翻译.min.js
- Angular-cookies.js
- 角度翻译插值messageformat.js
- 角度翻译存储cookie.js
- 消息格式.js
- en.js
- lt.js
我的应用程序配置(我尝试使用 cookieStorage:
myApp.config(['$translateProvider', function ($translateProvider) {
$translateProvider.translations('lt', {
"OTHER_LIKES" : "{peopleCount, plural, one {# kolega tai mėgsta} few {# kolegos tai mėgsta} other {# kolegų tai mėgsta}}",
"YOU_AND_OTHERS_LIKES" : "{peopleCount, plural, one {Tu ir # kolega tai mėgsta} few {Tu ir # kolegos tai mėgsta} other {Tu ir # kolegų tai mėgsta}}",
"YOU_LIKE" : "Tu mėgsti tai"
});
$translateProvider.translations('en', {
"OTHER_LIKES" : "{peopleCount, plural, one {# colleague likes this} few {# colleagues likes this} other {# colleagues likes this}}",
"YOU_AND_OTHERS_LIKES" : "{peopleCount, plural, one {You and # colleague likes this} few {You and # colleagues likes this} other {You and # colleagues likes this}}",
"YOU_LIKE" : "You like this"
});
$translateProvider.preferredLanguage('lt');
$translateProvider.fallbackLanguage('en');
$translateProvider.addInterpolation('$translateMessageFormatInterpolation');
$translateProvider.useCookieStorage();
}]);