The Easiest Way To Translate ‘Dokan’ or Any Other WordPress Plugins-Themes into Your Own Language
As the title says, here we will discuss the easiest and the quickest way to translate Dokan. Not only Dokan but this will work for any other WordPress plugin and theme as well.
However, if you are already an experienced WordPress user then you can directly jump into the ‘How to translate’ section to take further action.
So, let's get started and see the Dokan translation process step by step.
How Does Translation Work in WordPress?
If you are new to WordPress translation and don’t have any idea then you might find it hard to understand but don’t worry I got you! You will be a PRO in no time.
If you ever switched your site language from WordPress settings for the first time then you might have noticed that some of the menu tabs in the WP-Admin left sidebar to remain untranslated.
Also, If you have selected your local language during the WordPress installation and later installed some plugins you should have noticed the newly installed plugins’ tabs remain in English. Let’s see the below example.
As you can see in the above screenshot I have switched my site language to Spanish marked in green. However, did you notice the areas marked in red? Those strings remain in English. So what might have gone wrong?
If you look closely you will notice that only the default WordPress menus were translated automatically and all the other strings that are related to 3rd party plugins remained untranslated. This is because when you switch the site language WordPress creates a ‘language’ folder inside the ‘wp-content’ folder.
Now, if you look inside that ‘language’ folder you will see the translation files just like below.
So basically WordPress looks for the translation files inside the ‘language’ folder. The files marked in red are generated by WordPress automatically. This is why we see the default WordPress menus in translated language without doing anything.
However, 3rd party plugins or themes can’t do that. So you have to place the translation files manually or you can start from scratch but keep in mind that you can not simply place the translation file anywhere. There are some rules to follow.
Things To Consider Before Starting WordPress Plugin Translation
As mentioned above you need to follow some basic WordPress rules to make it work.
01. File name: (Text Domain)-(LocaleCode)
The file name is very important. Without a proper file name, WordPress won’t be able to recognize the translation file. As a result, the translations won’t be reflected. The file name structure mentioned above might get you confused if you are new to WordPress. Let’s see some examples:
Let’s say you want to translate the Dokan Lite plugin. First, you need to know the Text Domain of Dokan Lite plugin and then the Locale Code.
So where do you can find it?
Every plugin and theme has a PluginName.php file inside the plugin folder. So, there should be a file called ‘dokan.php' inside the Dokan Lite plugin folder.
Let’s go to /wp-content/plugins/dokan-lite
You can see the dokan.php file inside as expected. Now, let’s open the file. However, you can open the file using any good text editor.
After opening the file dokan.php you can easily see that the text domain of the plugin is dokan-lite.
Now you have the text-domain. We have one more thing to deal with. Here you have the text-domain to find out the locale code of the country language so that you can translate your site into.
For this particular case, as you are translating into Spanish. So it's better to find the locale code which is easier than the text-domain. Therefore, you just need to visit here and find the correct WordPress Locale.
Let’s find the WordPress Locale for Spanish (Spain) from the list.
According to the list, the WordPress Locale for Spanish (Spain) is es_ES. So, you have the text-domain and WordPress Locale.
So following the WordPress rule format & the correct file name for Dokan, the lite plugin is: (TextDomain)-(LocaleCode) = dokan-lite-es_ES
Let’s see more examples for other languages as well.
Spanish (Spain): dokan-lite-es_ES
German: dokan-lite-de_DE
French (France): dokan-lite-fr_FR
Arabic: dokan-lite-ar
Italian: dokan-lite-it_IT
02. File Location
Remember I mentioned earlier that WordPress has the translation files inside the language folder? Well, there are two locations where you can place your files:
For plugins: wp-content/languages/plugins. For themes: wp-content/languages/themes
OR
wp-content/ [plugins or themes]/ [plugin/theme-folder] /languages
It is required to put the files inside wp-content/languages/[plugins or themes].
This is a system folder. Why is that? Because if you place the files directly to the plugin/theme folder then your translation files will be removed. This is why it is a best practice to put the files inside the system folder so that you don’t lose the translations.
How To Translate Dokan (The Best WordPress Multivendor Plugin)
Now the time has come to see the dokan translation process here. To get the job done easily, follow the instruction very carefully.
01. Translating Dokan Lite
- Go to WP-Admin>Plugins>Add New. Now search for ‘Loco Translator’.
- After Installing and activating the plugin successfully. You should be able to see a menu called ‘Loco Translator’ on the left side bar.
- Now go to Loco Translate> Plugins. And you can easily see the list of plugins that are currently installed on your WordPress site.
Important note: You can go to Loco Translate> Themes if you want to translate a theme.
- From the list above you can see there are two files for the Dokan plugin (If you have the PRO version of Dokan).
Important Note: Dokan lite & Dokan Pro are dependent to each other, but act as individual plugins
In this case, You will need to translate both files. So first, let’s get started with the Dokan Lite.
- Now click on the ‘new language’ option and you will see the below screen.
- First, you need to choose the translation language. In our case, we will choose Spanish (Spain). Here you you'll see a default System location.
- Selecting the system location will prevent you to lose the important files if you update or mistakenly remove the plugin.
- Also, did you notice that the Loco Translator can detect the TextDomain and the WordPress Locale code automatically? So when you are using the Loco Translator you just don’t need to think much about these things except in some cases.
- Now hit the ‘Start Translating’ button and you will be redirected to the translation management window where you will be able to translate every single string of Dokan Lite.
- Now let’s try to translate a string from Dokan Lite and see if the translation is working. For example, you can translate the Dokan menu string that is located in the left sidebar.
- Search for the string ‘Dokan’ and translate into your local language.
- Now go to Settings> General and change the site language to Spanish to see if the translation is actually working or not.
- Nice! Our translation is working as expected.
02. Translating Dokan Pro
- When trying to translate Dokan Pro there’s some sort of error you'll be going to notice which is the Template missing.
- Even if you manage to get past this error by clicking on ‘Skip Template’ or ‘Create Template’ the end result will look like below.
- As you can see you have only 4 strings to translate! Something may be going wrong. Right?
Okay, Let’s fix that.
- Exit the translation editor screen first by clicking on ‘Dokan Pro’.
- Click on the Advanced tab. As you can see that the Template File is missing. The template file is basically a POT file that contains all the source strings of a plugin or a theme. The pot file can be found inside the language folder of the respective plugin folder.
- So in the case of Dokan Pro it should be language/dokan.pot.
- Also, the Text domain is not correct. Loco Translator tries to detect the Text Domain of a plugin or a theme automatically to make our life easy.
- The Text Domain of Dokan Pro is dokan. Also, the file prefix should be same as text domain.
- After correcting everything it should look like below.
- Now let’s go back and start translating.
All the source strings of Dokan Pro are now showing up. It worked! So, If you ever come across a problem like this while using the Loco Translator you know what to do.
When You Already Have The WordPress Plugin Translation File
Most of the plugins have ready-made translation files. Some are fully translated and some are partially translated. You can use those files so that you don’t need to start from the scratch.
If the file is partially translated then we can use that file and translate the remaining strings only. Dokan has translation projects as well.
Translation files of Dokan Lite can be found here.
Translation files of Dokan Pro can be found here.
Let’s Translate Dokan Lite by Using an Existing File
Click on the link mentioned above.
As we can see that the Spanish translation is already 96% complete we don’t need to start from scratch. We can download this translation file and only translate the remaining 4%.
After clicking on the Spanish (Spain) we are redirected to the below screen. We can choose either Development or Stable release. Since both are the same we can go with the Stable one. Click on Stable.
To download the file go down below and select ‘only matching filter’ as ‘.po’ and click export.
Similarly, select ‘only matching filter’ as ‘.mo’ and click export.
Now we have two files the following names: wp-plugins-dokan-lite-stable-es.po and wp-plugins-dokan-lite-stable-es.mo
If you are reading this article from the beginning then you already know that the file name is not correct and we need to fix it. The correct file names for Spanish are:
dokan-lite-es_ES.po
dokan-lite-es_ES.mo
Let’s rename the files first. It should look like this.
Great! We are almost done. Now we just need to put the files to the correct location. We have already discussed that the translation files should be placed in the system folder.
wp-content/languages/plugins/
Now that we have placed the files to the mentioned location. Let’s go to the Loco Translator and see the result.
As you can see the Spanish translation is 97% complete and we only have 51 remaining strings that we can simply translate using the Loco Translation editor.
WordPress Plugin Translation: Need to Have Loco Translator or Not
If you already have the ‘.PO' and the ‘.MO' files you can simply put them inside the correct mentioned location and the translations should reflect immediately upon page refresh.
For that, you don’t need the Loco translator. You just need to make sure that the file name is correct. However, if you wish to edit or translate the remaining strings then you are going to need the Loco translator.