Wordpress implements the GNU gettext localization framework to provide localization infrastructure (.po/.mo files). You do not need to create .po/.mo files manually so that's all you need to know about the mechanism. But if you're a developer or you’re learning about these technicalities, you can visit the Translating WordPress documentation page.
Before you start
To localize your theme and plugins, you can make a directory and name it "languages" located in "wp-content", if it does not already exist. Take note, your web server has write permissions to this directory. If you're not familiar with this subject, you can read more about it at Wordpress file permissions.
To prepare a translation, you can choose from different plugins and tools.
If you want to use a desktop program, we recommend that you use the free poEdit plugin.
Loco Translate plugin
In our opinion, there is a more efficient way to handle theme/plugins translations. This is to use the Loco Translate plugin. It is always good to have all the necessary tools handy, without having to use external programs. The "Loco Translate" plugin has also features an online alternative, which makes it useful for editors that have no access to your admin panel.
The WPML is the one of the most powerful plugins used to translate Wordpress. It's not free, costing around $79) but it's worth the price. If you decide to use it, you can read the String Translation section to learn how to translate theme/plugins phrases, or anything that doesn’t fall inside posts, pages, or taxonomy content.
Translate with the Loco Translate plugin (recommended)
1. Install the Loco Translate plugin.
2. Go to the WP Admin Panel › Loco Translate.
3. Find your target theme or plug in on the list (screen 1, point 1)
4. Click on the "New language" section (screen 1, point 2).
5. Select your language (for "Spanish", code "es_ES").Make sure that this translation will be loaded only if your site language in WordPress Admin › Settings › General › Language is similar.
6. Under the language code field, you will notice an option to on where to store your translation. Select "create in global languages directory" option. If you don't see any option that's okay, the translatio
will be stored in your global directory. Then click the "Start translating" section.
To generate all necessary translation files, you can translate all phrases and click "Save"
If everything goes according to plan, you will find translation files under the directory:
Keep translations safe even after future updates
Because we don't utilize the theme/plugins related directories to store translations, this does not mean that your translations are not safe. All of your custom translations are stored in the wp-content/languages directory. So unless you reinstall the entire Wordpress application, all your data is safe. You can even update the theme and each plugin without losing your translations.