Back to Home

Making Your Chrome Plugins Multilingual

chrome

Making Your Chrome Plugins Multilingual

    image
    Do you have a plugin for Chrome in Russian or in English, but the audience of the plugin is much wider and not only in the language of your choice? Then I ask for a tackle.

    We will do support for Russian and English, but no one bothers you to do support for other languages.
    To make your plugin multilingual, we go to manifest.json from the beginning
    and add the following lines:
    This line indicates which language will be used by default, in case the translation is not available for the user's language.
    "default_locale": "en",
    Now, in place of the standard description of the plug-write
    "description": "__MSG_chrome_extension_description__",
    You can make and for the name of the plugin
    "name": "__MSG_chrome_extension_name__",
    After all manipulations will look something like this
    image

    Creating localization files


    To do this, we create a folder with the name _locales in the plugin root. We
    create the en and ru
    folders in it. We create the messages.json file in the folders.
    With the following contents, we write the same file in the en folder in the same file, but in English if you want to make support for any language then create the appropriate folder and file in it, and be sure to change the value of the last lines Here are the languages ​​that Chrome am ar bg bn ca cs da de el en en_GB en_US es es_419 et fi fil fr gu he hi hr hu id it ja kn ko lt supports lv ml mr nb nl or pl pt pt_BR pt_PT ro ru sk sl sr sv sw ta te th tr uk vi zh zh_CN zh_TW
    {
    "chrome_extension_description": {
    "message": "Описание плагина."
    },
    "chrome_extension_name": {
    "message": "Имя плагина"
    },
    "some_string": {
    "message": "Текст"
    },

    "lang": {
    "message": "ru"
    }
    }


    {
    "chrome_extension_description": {
    "message": "Extension description."
    },
    "chrome_extension_name": {
    "message": "Plugin name"
    },
    "some_string": {
    "message": "some text"
    },

    "lang": {
    "message": "en"
    }
    }


    "lang": {
    "message": "en"
    }





    Now let's move on to the plugin settings, namely options.html, let's say you want to make a header in different languages ​​for this we write inside the tag

    This operator communicates with Api chrome and takes the parameters we need above from the files that we created above

    And let's return to the multilingual header.

    Suppose before that the plugin says “some text” in the plugin so
    that the label is in several languages, replace it with

    This line refers to the lang function and takes the “some_string”

    parameter from the files created earlier. The parameter in the files is specified as follows: And now for In order to translate all the inscriptions into multilingual ones, from the beginning we add their meaning in the files, then we write the line in the place of the source texts That's all.

    "some_string": {
    "message": "some text"
    },





    Live example of multilingualism Auto HD for YouTube plugin

    Read Next