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 l
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.
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.