Firefox Web扩展国际化错误

时间:2017-08-23 18:52:44

标签: firefox-webextensions

我昨天开始在55.0.2版本上开发我的第一个Firefox Web扩展。我想为该扩展添加不同的语言,所以我在官方网站上阅读了这个主题:https://developer.mozilla.org/fr/Add-ons/WebExtensions/Internationalization

然而,事情并没有按照他们的意愿进行,因为现在每当我尝试使用about:debugging加载我的应用程序时,它会不断弹出此错误消息“安装期间出错:扩展无效”。

我搜索了一些可能导致此问题的内容,我发现的内容完全是奇怪的。每当我在_locales文件夹中有一个像“en”或“fr”这样的文件夹时,Firefox就会不断向我显示该错误消息。

我试图在manifest.json中添加一个默认的语言环境来修复它,但是没有运气,它不起作用。我尝试通过更改扩展名称&尽可能简单地使我的messages.json变得简单。扩展说明,没有运气。

由于我不明白的原因,这些子文件夹阻止我添加不同的语言。

这是我的manifest.json:

{
    "manifest_version": 2,
    "default_locale": "en",
    "name": "__MSG_extensionName__",
    "description": "__MSG_extensionDescription__",
    "version": "1.0",
    "applications": {
        "gecko":{

        }
    },

    "permissions": [
        "contextMenus",
        "activeTab"
    ],

    "background": {
        "scripts": ["ddo.js"]
    },

    "browser_action": {
        "default_title": "Download Destination Organizer"
    }
}

这是我的messages.json里面_locales里面的“en”子文件夹:

{
  "extensionName": {
    "message": "DDO",
    "description": "Name of the extension."
  },

  "extensionDescription": {
    "message": "Insert description here",
    "description": "Description of the extension."
  }

}

这是我在_locales里面的“fr”子文件夹里面的messages.json:

{
  "extensionName": {
    "message": "DDO",
    "description": "Name of the extension."
  },

  "extensionDescription": {
    "message": "Insérer la description ici.",
    "description": "Description of the extension."
  }

}

2 个答案:

答案 0 :(得分:1)

使用Mozilla存储库中的官方web-ext工具:https://github.com/mozilla/web-ext

当我使用此命令(在MacOS上)运行示例时,它对我有用:

web-ext run --firefox

您也可以使用以下命令在firefox开发人员版中运行它:

web-ext run --firefox /Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox

此外,您可以使用详细选项(-v)运行它,以确切了解失败问题的位置:

web-ext run --firefox -v

这是我的架构(我没有改变你提供的内容,我只添加了清单中描述的ddo.js文件 - ddo.js文件包含console.log):

|- _locales
|  |- en
|  |  |- messages.json
|  |
|  |- fr
|  |  |- messages.json
|
|- ddo.js
|- manifest.json

答案 1 :(得分:0)

您是否正在加载压缩的WebExtension?

您如何压缩它?

您必须使用"compatible"程序对其进行压缩,例如,当我使用Compress-Archive通过powershell命令行对其进行压缩时,会出现该错误,但是如果我使用Windows send to -> Compressed (zipped) folder菜单对其进行压缩或使用zip的7z默认选项,则效果会很好。

相关问题