【问题标题】:missing key i18next message but it's working缺少关键 i18next 消息,但它正在工作
【发布时间】:2017-10-25 02:15:58
【问题描述】:

我不断收到这条消息

i18next::translator: missingKey es-AR translation El campo Ciudad es obligatorio. El campo Ciudad es obligatorio.
am-trips-my-trips.module.js:5 i18next::translator: missingKey es-AR translation El campo Ciudad es obligatorio. El campo Ciudad es obligatorio.

文本显示用户尝试提交所需的空白输入。

event-form.component.js

  get originRequired(){
                return this.$i18next.t('event-form.' + this.event.type + '.originRequired', {originLabel: this.originLabel})
            }

event-form.json

{
    "event-form": {
        "hotel": {
            "originRequired": "El campo {{originLabel}} es obligatorio.",
        }
}

我应该这样翻译吗?不希望它作为默认值传递!我想把它作为钥匙传递! 尽管它正在工作,这是因为它是默认值,但我想将它作为插值的键传递。谢谢

【问题讨论】:

    标签: angularjs internationalization i18next


    【解决方案1】:

    不是很理解你的问题。做了一个小jsfiddle:

    i18next.init({
      lng: 'en',
      resources: {
         en: {
           translation: {
             "event-form": {
               "hotel": {
                 "originRequired": "El campo {{originLabel}} es obligatorio.",
              }
            }
          }
        }
      }
    }, function(err, t) {
      // initialized and ready to go!
      document.getElementById('output').innerHTML = i18next.t('event-form.hotel.originRequired', { originLabel: 'Ciudad' });
    });
    

    https://jsfiddle.net/jamuhl/8339motk/

    如果密钥存在,则不会丢失。你得到一个丢失的原因它丢失了。

    你的意思是:不希望它作为默认值传递!我想把它作为钥匙传递!

    【讨论】:

    • 当用户提交表单并留下空白输入时,会显示此消息。它们看起来像一个警告
    • 翻译成功了!但在初始化时没有。因为没有显示该文本
    • 在 i18next 加载资源之前看起来像角度渲染 - 将角度引导移动到 i18next.init 回调应该可以解决它
    猜你喜欢
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-20
    相关资源
    最近更新 更多