Translate Your Theme – Basics
Storing Translation Files
Storing translation files in the right directory is very important to make sure the translations you’ve downloaded, created or edited. The best way to do this is store it inside the Languages folder located inside the wp-content folder.
To Store Theme Translation Files
- Place your theme translation files inside wp-content/languages/themes folder. If you don’t have the languages and themes folder, simply create the languages folder, and the themes folder inside it.
- Updating the theme will not overwrite the wp-content folder. Storing your translation files here will ensure they stay intact during updates.
- When storing your language files, remember that the file structure is different and must include the theme name, as well. For example, if the language files are in the Deutsch language, the file names would be de_DE.mo and de_DE.po.
The Translation Process
This section will explain where you can find the files needed for translation and what these files are for. Inside Our Main Theme folder, you will find a folder called Languages. If you have downloaded the Installable WordPress Package file, you will find these files in the Languages folder:
- independent.pot – A list of all the text strings used in the Theme files. These text strings are in the English language, and can contain a translation for each text string.
- If your language is not already included, you need to create a new .po file from the original independent.pot located in the Languages folder, translate all text strings, then save the .po file with your language code.
- Either you are setting up a completely new language file or you just want to edit translated pre-built language files, follow the steps to make easy.
- The language files can also be used if you only want to translate a small portion of the theme, or one specific area. You do not have to translate the entire theme, you can choose what you translate inside the independent.pot file. This is the preferred method for translation.
Edit The .pot file Using POEdit Software
To edit the .pot files, you need to download the POEdit software. Click on this link to download poedit.net. There are different editors for editing .po files, but POEdit is easy to use, it is available for all platforms and it is freeware.
- Open POEdit and select the Create New Translation button to open the independent.pot.
- Once it has loaded, You will find all English text strings in the left column called Source Text. Once you add translations, they will show up in the right column under Translation.
- Choose the line you want to translate. In the lower right section of the POEdit window, you will find a text area where you can add the correct translation.
- When you are done translating all the needed text strings into your desired language, save the file with the theme name and your language code.
- For example, if you were translating to the Deutsch language, you would save it as de_DE.po. The corresponding .mo file will be auto created.
To Edit A Pre-Built Language File
Everytime you update the .pot file, make sure to upload both .po and the compiled .mo file as correct file name. The correct file name is the theme name and your language code. For example, de_DE.po.
- Open the .pot file of your preferred language in POEdit and search for the line you want to change. Select the Edit button to change, then select the Find option.
- In the Search Window, type the text string you are searching. Once it is selected, replace the text in the Translation text area in the lower part of the window with your prefered translation.
- Repeat the steps to edit another text.
- Once done with your translations, Save the file and .mo file will be auto created with updated.