5

What's different between _x() and _(). For example: if a1 can translate as:

  • a1 has meaning x1;
  • a1 has meaning x2;

How _x() function to get value x1 or x2?

8

_x() let's you add a context to your strings. This is useful when you are using the same string in different places. This string may need different translations depending on the language.

Your example would be :

echo 'a1 in context 1 ' . _x('a1', 'context1', 'mydomain');
echo 'a1 in context 2 ' . _x('a1', 'context2', 'mydomain');

There are more examples in this article.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.