本地化(l10n):为我的mozilla插件设置默认语言 [英] Localization (l10n) : Set Default Language for my mozilla addon

查看:158
本文介绍了本地化(l10n):为我的mozilla插件设置默认语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个mozilla插件并实现l10n。我的问题是,


  • 如何将默认语言设置为我的插件?(当我的插件不支持语言,它切换到默认语言)


  • 当Mozilla Firefox的语言改变时,插件会改变它的语言环境语言吗? $ b

  • 如何更改我的firefox浏览器语言?

  • 在经典的引导程序插件中,您不需要设置默认值。

    经典引导程序



    Firefox会自动找出用户浏览器和插件所在位置之间最接近的语言环境。

    JPM



    你在做一个JPM / SDK的插件?如果您正在本地化首选项,则必须在 package.json 中初始设置一个字符串:

     preferences:[
    {
    name:imagePath,
    type:file,
    value ,
    title:图像文件路径,
    description:计算机上的图标路径,停靠图标应该设置为

    $ bname:restoreDefault,
    type:control,
    title:default locale:Restore Default,
    description :这是从package.json ::如果你已经改变了你的图标,并且想要恢复默认的Firefox图标,请点击这个按钮,
    label:这是来自package.json :: Restore






    $ b因此,默认值是你在那里设置的值。如果firefox找不到匹配的语言环境提供它将使用package.json字符串。

    因此,例如本地化 restoreDefault

    code>字符串,您将创建一个 en-US.properties 文件并将其放在名为 locale 像这样:

      restoreDefault_title = blah恢复默认等值
    restoreDefault_description = blah如果您更改了图标并且想要恢复默认的Firefox图标,点击这个buttonblah
    restoreDefault_label = blahRestoreblah

    现在设置您的浏览器语言环境转到about:config,然后将首选项 general.useragent.locale 更改为 en-US (将其更改为 es ),然后加载您的首选项页面(可能需要在更改 general.useragent.locale )。现在因为你的插件没有 es.properties ,你会看到来自package.json的字符串。将你的 general.useragent.locale 设置回en-us,然后重新启动你的浏览器,回到你的插件页面,你会看到属性文件中的字符串。


    I am developing a mozilla addon and implementing l10n. My questions are ,

    • How to set default language to my addon?(This works when my addon doesn't support a language, it switches to default language)

    • Will addon change its locale language when the language of the Mozilla Firefox changes?

    • How to change my firefox browser language?

    解决方案

    Classic Bootstrap

    In classic bootstrap addons, you don't set a default. Firefox automatically figures out the closest locale between the users browser and from whatever locales your addon has.

    JPM

    Are you doing a JPM/SDK addon? If you are localizing the preferences, you have to initially set a string in the package.json:

    "preferences": [
        {
            "name": "imagePath",
            "type": "file",
            "value": "",
            "title": "Image File Path",
            "description": "A path to an image on your computer that the dock icon should be set to"
        },
        {
            "name": "restoreDefault",
            "type": "control",
            "title": "default locale:Restore Default",
            "description": "this is from package.json:: If you have changed your icon, and want to restore the default Firefox icon, click this button",
            "label": "this is from package.json:: Restore"
        }
    ]
    

    So the default is whatever you set there. If firefox cannot find a match to the locales provided it will use the string from package.json.

    So for exmaple to localize the restoreDefault strings you would create a en-US.properties file and drop it in a folder named locale like this:

    restoreDefault_title=blah Restore Default blah
    restoreDefault_description=blahIf you have changed your icon, and want to restore the default Firefox icon, click this buttonblah
    restoreDefault_label=blahRestoreblah
    

    So now set your browser locale to english by going to about:config and then change the preference general.useragent.locale to something other then en-US (change it to es) for this example then load your preferences page (may need to restart browser after changing general.useragent.locale). Now because your addon does not have es.properties you will see the strings from package.json. Set your general.useragent.locale back to en-us and then restart your browser, and go back to your addon pref page, and you will see the strings from the properties file.

    这篇关于本地化(l10n):为我的mozilla插件设置默认语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆