Translate Wordpress strings from Portuguese to English

3

I have a Wordpress installation in pt-br and I have searched for numerous ways to translate theme, strings but none have worked. Most pick up a theme that is standard in English and I translate it into Portuguese.

I needed to "translate" some strings from the menu Portuguese to English, I got to use wpml but it totally messed up my theme. Does anyone have any simpler ideas on how to translate in the hand?

    
asked by anonymous 28.10.2015 / 16:15

2 answers

2

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

    
30.10.2015 / 15:51
3

I did not find a solution more practical, I changed the strings manually even, according to the? Wordang? lang, follow my solution:

 <?php 
              $mylocale = get_bloginfo('language'); //Pega o lang padrão do tema
              if($mylocale == 'pt-BR') { ?>
             <p>Palavra em português</p>
<?php }
             elseif($mylocale == 'en-US'){ ?>

             <p>Palavra em inglês</p>

<?php }
?>
    
28.10.2015 / 16:56