bobbyrne01
bobbyrne01

Reputation: 6745

Performing localization of menulist using addon sdk

Have a menulist preference in my addon and I'm trying to localize it.
The preference works fine from a functional point of view but when I change my browser's locale to es-ES, I still see the English translations.
Is there a declaration error here?
The official documentation does not give full examples of it's usage.
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/l10n.html

package.json:

{
    "name": "extensions.savetexttofile.saveMode",
    "title": "Save mode?",
    "type": "menulist",
    "value": 0,
    "options": [
        {
            "value": "0",
            "label": "Create new file"
        },
        {
            "value": "1",
            "label": "Append to existing file"
        }
    ]
}]

tail -n 4 locale/es-ES.properties:

extensions.savetexttofile.saveMode_title= modo de ahorro de?
extensions.savetexttofile.saveMode_description= Método para guardar texto:
extensions.savetexttofile.saveMode_options.0= Crear un archivo nuevo
extensions.savetexttofile.saveMode_options.1= Añadir a un archivo existente

Upvotes: 1

Views: 146

Answers (1)

nmaier
nmaier

Reputation: 33162

For options, you must use the label of the option in your properties file, like so (tested):

extensions.savetexttofile.saveMode_title= modo de ahorro de?
extensions.savetexttofile.saveMode_description= Método para guardar texto:
extensions.savetexttofile.saveMode_options.Create new file= Crear un archivo nuevo
extensions.savetexttofile.saveMode_options.Append to existing file= Añadir a un archivo existente

This looks kinda nasty, so it might be advisable to use a "generic" name in your package.json like createand append and localize that as saveMode_options.create= in all locales, including your en-US.properties.

On an unrelated note: It is not necessary to prefix your SDK prefs with extensions.savetexttofile.. The add-on SDK already prefixes it with your add-on id, so that you end up with a double prefix like extensions.jid1-pL3SKrUpOJo04Q@jetpack.extensions.savetexttofile.saveMode)

Upvotes: 1

Related Questions