简体   繁体   中英

Is it possible to change default fallback message i18n-js?

I want to change fallback message on missing translation for i18n-js ([missing translation "en....."]) Is it possible and how to?

In library itself it is defined this way:

I18n.missingTranslation = function() {
  var message = '[missing "' + this.currentLocale()
    , count = arguments.length
  ;

  for (var i = 0; i < count; i++) {
    message += "." + arguments[i];
  }

  message += '" translation]';

  return message;
};

you can replace this with your own implementation by reassigning I18n.missingTranslation after library is already evaluated.

Thanks @Vasfed, but now i know easier way to do this.

Just add:

I18n.t("some.missing.scope", {defaults: [{message: "Some message"}]});

Instead of [missing translation "bla.bla.bla" ] you will get "Some message".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM