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 your chosen language? Then please roll.
We will do support for Russian and English, but no one bothers you to do support for other languages.
In order to make your plugin multilingual from the beginning, we go to manifest.json
And add the following lines:
This line indicates which language will be used by default, in cases where the translation for the user's language is not available.
Now, in place of the standard description of the plugin we write
You can also do for the name of the plugin
After the manipulations, everything will look something like this.
Creating localization files
To do this, in the root of the plugin create a folder named _locales
In it we create folders en
Create the file messages.json
With the following content
"message": " ."
"message": " "
In the folder en
in the same file we write the same but in English
"message": "Extension description."
"message": "Plugin name"
"message": "some text"
If you want to make support for any other 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 supports.
am ar bg bn ca cs da de el en_GB en_US es es_419 et fiil fr gu gu hi hr hu id it ja kn ko lt lv ml mr nb nl or pl pt pt_BR pt_PT ro ru sk sl sr sw ta ta th r uk vi zh zh_CN zh_TW
Now let's go into the settings of the plugin namely in options.html, let's say you want to make a title in different languages for this we write inside the tag
This operator communicates with Api chrome and takes the parameters we need from the files we created above.
And back to the multilanguage title.
Let before that in the plugin in the title it was written "some text"
What would this inscription be in several languages replace it with
This line refers to the lang function and takes the parameter "some_string" from the files created earlier.
The parameter in the files is indicated as follows:
"message": "some text"
And now, in order to translate all the inscriptions into multilanguage from the beginning, we add their meaning in the files, then we write the line to the place of source texts
A live example of the work of the multi-language pluginAuto HD for YouTube