what’s different between _x() and _()

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?

Related posts

Leave a Reply

1 comment

  1. _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.