Search code examples
firefoxlocalizationfirefox-addon-sdkbuilder

firefox-addon-sdk localization of add-on options


In firefox Add-On builder there is a possibility to drop add-on preferences into the properties window in an "Extra package.json Properties" field.

The preferences for localization look like this:

{    "preferences": [
        {
            "type": "string", 
            "name": "myStringPref", 
            "value": "this is the default string value", 
            "title": "My String Pref"
        }
        ....
    ]}
}

Question: How can i localize the labels of the addon-options?


Solution

  • Here is essential of manual localization.

    1. create locale files in json format
    2. create locale listing file in json format
    3. download addon package(xpi file) from Add-on Builder
    4. rename file extension .xpi to .zip
    5. expand zip file
    6. create locale folder in the root of addon
    7. copy locale files into locale folder
    8. copy locale listing file into root folder
    9. zip all files and folders on root folder.
    10. rename file extension .zip to .xpi

    file tree:

    my-addon
        |   locales.json
        |
        +---data
        +---lib
        +---locale
            en-US.json
            fr-FR.json
            ja-JP.json
    

    samples:

    locales.json
    {"locales":[
        "en-US",
        "fr-FR",
        "ja-JP"
    ]}
    
    en-US.json
    {
    "test": "test en-US",
    "test2": "test2 en-US"
    }
    
    fr-FR.json
    {
    "test": "test fr-FR",
    "test2": "test2 fr-FR"
    }
    
    ja-JP.json
    {
    "test": "test ja-JP",
    "test2": "test2 ja-JP"
    }