火狐浏览器扩展国际化错误



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

但是,事情并没有按预期进行,因为现在每当我尝试使用 about:debugging 加载我的应用程序时,它都会弹出此错误消息"安装过程中出现错误:扩展无效"。

我已经搜索了一些可能导致此问题的原因,我发现的是完全奇怪的。每当我的_locales文件夹中有"en"或"fr"这样的文件夹时,Firefox 都会不断向我显示该错误消息。

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

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

这是我的清单.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"
}
}

这是我在_locales内的"en"子文件夹中的 messages.json:

{
"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."
}
}

使用 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

您是否正在加载压缩的网络扩展?

你怎么压缩它?

您必须使用"compatible"程序压缩它,例如,当我使用 Compress-Archive 通过 powershell 命令行压缩它时,我会收到该错误,但是如果我使用 Windowssend to -> Compressed (zipped) folder菜单或 7z 默认选项 zip 压缩它,那么它就可以了。

最新更新