Javascript 如何在angularjs 1.6上使用i18n

Javascript 如何在angularjs 1.6上使用i18n,javascript,angularjs,json,i18next,Javascript,Angularjs,Json,I18next,我应该如何使用i18n,以便变量“title”从传输的json中获取值。它应该返回“Mis viajes”,而现在它没有返回任何内容。谢谢 trips-header.jade 我这样做了,屏幕上显示“0” .trips-header .background-image .header-content p.title.ng-i18next {{ title | i18next}} p.sub-title.ng-i18next {{ sub-

我应该如何使用i18n,以便变量“title”从传输的json中获取值。它应该返回“Mis viajes”,而现在它没有返回任何内容。谢谢 trips-header.jade

我这样做了,屏幕上显示“0”

.trips-header
    .background-image
    .header-content
        p.title.ng-i18next {{   title | i18next}} 
        p.sub-title.ng-i18next {{   sub-title | i18next}} 
Mi json

 {
  "es-AR": {
      "translation": {
         "title":"Mis Viajes!",
         "sub-title": " te ayuda a planificar y organizar tus viajes."
      }
  }
}

下面是一个示例方法。您希望html看起来像这样:

<h1>{{'hello' | i18next}}</h1>
你的翻译是:

{
  "es-AR": {
      "translation": {
          "hello":"hi!"
       }
    }
}
您的i18n in angular应正确配置:

yourApp.config( ['$i18nextProvider',function( $i18nextProvider ) {
    $i18nextProvider.options = {
        lng: 'es-AR', //select or detect from browser
        useCookie: false,
        useLocalStorage: false,
        fallbackLng: 'en',
        resGetPath:  l_prefix + 'locales/__lng__/__ns__.json',
        defaultLoadingValue: ''
    }
// file is expected to be locales/es-AR/translation.json
..... remaining of the config

编辑:添加了“hello”周围的引号。现在它被视为一个文本而不是一个变量。

你在互联网上看过吗?对但我不知道如何申请一门课。我该怎么做?(使用我的示例作为参考,谢谢)确保您的角度侧配置正确。检查开发工具中的元素。应正确呈现html结构。此外,您可能希望将子标题更改为不包含“-”的内容,谢谢!我会查一查的!当我在开发工具上得到i18next::translator:missingKey es AR translation 0 0时,我的情况很糟糕。我已经忘记了“你好”这句话。在代码中。最重要的是,确保在呈现时加载翻译字符串(因为这是一个异步操作)。
yourApp.config( ['$i18nextProvider',function( $i18nextProvider ) {
    $i18nextProvider.options = {
        lng: 'es-AR', //select or detect from browser
        useCookie: false,
        useLocalStorage: false,
        fallbackLng: 'en',
        resGetPath:  l_prefix + 'locales/__lng__/__ns__.json',
        defaultLoadingValue: ''
    }
// file is expected to be locales/es-AR/translation.json
..... remaining of the config