The default solution in Wordpress for translations is Internationalization. You prepare your theme/plugin so that it can receive different translations. Basically, you embrace your strings
text in methods that WP itself provides. Documentation
$hello = __( 'Hello, dear user!', 'my-text-domain' );
The method __()
, in addition to assigning the value Hello, Dear user! for the variable, also adds it to the domain my-text-Domain. If you need to do echo
within your code, you use the method _e()
, as follows:
_e( 'Using this option you will make a fortune!', 'my-text-domain' );
After having all your code prepared, with the strings
within a domain, you need to generate a file .pot
which will contain all the strings
internationalized of your code. When I need to do this, I use the Easypo.
In possession of the file .pot
, you can use the Poedit to translate all the strings
and generate a new domain. Then just set the locale
and everything must work. This process makes VERY MUCH easier maintenance of translations.
Here and here you can read (in English) two excellent articles on how to internationalize your theme/plugin. Also have an interesting discussion on this here
Already tried to edit the files directly?
– Amanda Lima
@Amandalima, I tried it with poedit (I don’t know if this is it directly), but it doesn’t find my custom strings
– haykou
Take a look here on this question. If the theme is prepared for "Localization", this solution will help you. Otherwise, the only solution is as @Amandalima said, change the strings in the files themselves.
– Chun
@haykou, if there are few strings you need to translate, open the Wordpress file with any text editor (Notepad++ in the case of Windows, Gedit in the case of Linux), look for the string and replace it with the translated word.
– Amanda Lima
The ideal would be to show an example of how this theme is.
– brasofilo