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% of text% in methods that WP itself provides. From the documentation
$hello = __( 'Hello, dear user!', 'my-text-domain' );
The strings
method, in addition to assigning the value Hello, dear user! to the variable, also adds it to the domain my-text-domain . If you need to __()
within your code, you use the echo
method, as follows:
_e( 'Using this option you will make a fortune!', 'my-text-domain' );
Once you have all your code ready, with _e()
inside a domain, you need to generate a strings
file that will contain all% internationalized% of your code. When I need to do this, I use EasyPO .
Possessing the .pot
file, you can use Poedit to translate all strings
and generate a new domain. Then just set the .pot
and everything should work. This process makes VERY easier to maintain translations.
Here and here