angular translate加载json文件

时间:2016-04-09 12:31:40

标签: javascript angularjs angular-translate

关于使用angular-translate的页面翻译,我遇到以下问题:

在输入页面上,过滤器仅显示ID,但当我点击其他页面时,它会显示翻译。

我的配置代码是:

.config(function ($translateProvider) {

$translateProvider.useStaticFilesLoader({
  prefix: 'languages/',
  suffix: '.json'
});
$translateProvider.fallbackLanguage('en_US');   
$translateProvider.determinePreferredLanguage();})

但是,如果直接在配置方法中设置翻译json,它就可以工作。

.config(function ($translateProvider) {       
$translateProvider.translations('en_US', {
  "USERNAME": "Username",
  "PASSWORD": "Password",
  "JOBS": "Jobs",
  "JOB": "Job",
  "ImageSequenceNumber": "Image Sequence Number",
  "Attach": "Attach",
  "ShareLink": "Share link",
  "HangoutCode": "or hangout code",
  "TakeNewShots": "Take new shots",
  "Shared": "Shared",
  "NoAccountYet": "Don't have account yet?",
  "SignUp": "Sign Up"
});
$translateProvider.fallbackLanguage('en_US');
$translateProvider.determinePreferredLanguage();
  })

HTML code:

<input type="text" placeholder = "{{ 'USERNAME' | translate}}" ng-model="data.username">

提前感谢任何建议!

0 个答案:

没有答案