S
S
Shigaev.2020-06-30 17:21:32
Machine translation from one language to another
Shigaev., 2020-06-30 17:21:32

How to finally solve the final question with translations in Wordpress?

I would not like new holivars about Loco Translate and Say What. I want gettext pulp.

How to replace a single line without variables is approximately clear:

function my_text_strings( $translated_text, $text, $domain ) {
  switch ( $translated_text ) {
    case 'Отправить комментарий' :
      $translated_text = __( 'Ругать', 'psycopypsycopy' );
      break;
    case 'Ответить' :
      $translated_text = __( 'Ответочка', 'psycopypsycopy' );
      break;
    case 'Поиск' :
      $translated_text = __( ' ', 'psycopypsycopy' );
      break;
  }
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );


But things like this don't work here:
<a href=\"%1$s\" aria-label=\"%2$s\">Вы вошли как %3$s</a>. <a href=\"%4$s\">Выйти?</a>
And this is logical, albeit pichyalno. How to get rid of pichal? What would the correct construction look like for something like this?

If anything, this is in Twenty Twenty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lord_Dantes, 2020-07-29
@Lord_Dantes

Looking for a translation plugin?
Try the banal qTranslateX, just be careful there is a conflict with the ACF version, like either ACF or a plugin you need to install the previous version. There, the text can be translated literally in code: the condition will be something likeif (site = 'ru') echo "привет"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question