最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

firefox addon webextensions - Web extension `messages.json` translation include other translation from same file - Stack Overflo

programmeradmin1浏览0评论

For a web extension messages.json translation file, is it possible that a translation includes another translation? That would be useful when you want to avoid duplication.

For example something like:

{
  "greeting": {
    "message": "Hello, $NAME$!",
    "placeholders": {
      "name": {
        "content": "$first_name$"
      }
    }
  },
  "first_name": {
    "message": "John"
  }
}

Neither the above approach of referring to another message using $<name>$ nor using __MSG_<name>__ within messages.json seem to work. I am looking for something which ideally works for Chrome and Firefox.

A workaround might be to nest getMessage calls and use $1 as placeholder in the message, but that is rather verbose and error-prone because every caller which wants to obtain the translation has to do this:

browser.i18n.getMessage('greeting', browser.i18n.getMessage('first_name'))

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论