Translation ready code format for taxonomy

_x( 'Categories', 'taxonomy general name' ) does it make taxonomy
general name
a text domain? wont it resulting in multiple
translation?

That taxonomy general name is the gettext or translation context used in the POT file. The text domain is the third parameter, which defaults to default.

  • From the Codex:

    Sometimes a single term is used in several contexts. Although it is
    one and the same word in English, it may need to be translated
    differently in some languages. For example, the word “Post” can be
    used both as a verb (“Click here to post your comment”) and as a noun
    (“Edit this post”). In such cases, the _x() function should be used.
    It is similar to __(), but it has an additional second argument —
    the context:

    if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun', 'my-text-domain' );
    if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback', 'my-text-domain' );
    if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback', 'my-text-domain' );
    ...
    // some other place in the code
    echo _x( 'Comment', 'column name', 'my-text-domain' );
    

wont it resulting in multiple translation?” — yes, it would. But that’s why the _x() has the context parameter. It helps you (as the developer) in retrieving the proper translation based on the context. (The context must always be specified when calling _x().)


__( 'All Categories' ),__( 'Edit Category' ) etc does not seems to
have any text domain, is it required?

Just like the _x() function, when calling __(), _e(), etc. without specifying a text domain, the text domain defaults to default; therefore:

  • __( 'All Categories' ) is equivalent to __( 'All Categories', 'default' )

  • __( 'Edit Category' ) is equivalent to __( 'Edit Category', 'default' )

I.e. The text domain is optional, in terms of the __() usage.

If you want your plugin/theme to be translatable (i.e. localized/internationalized), then yes, your plugin/theme should have a text domain, and always use it when using __(), _e(), or the other translation/gettext functions in WordPress.


Hope that helps, and for an in-depth guide on internationalization and localization in WordPress, check out the Codex. =)


UPDATE

Here’s a, hopefully :), more precise explanation regarding the default text domain:

  1. When WordPress loads, it will load the MO (.mo) files for the default text domain which has default as its unique identifier. The MO files are by default stored in wp-content/languages; so if your site’s language is Italiano, one of the MO files loaded into the text domain default is wp-content/languages/it_IT.mo.

  2. When for example, you call the __() function without specifying a text domain, or by using the text domain default, like so:

    __( 'All Categories' )
    __( 'All Categories', 'default' )
    

    then WordPress will use the translation entries parsed from the default‘s MO files (e.g. wp-content/languages/it_IT.mo) and lookup the translation of the text in those translation entries.

So if you want WordPress to lookup in the translation entries parsed from the MO file(s) of a theme or plugin, make sure to specify the correct text domain, like so:

__( 'All Categories', 'my-theme' )
__( 'All Categories', 'my-plugin' )

Because omitting the text domain (or setting it to default) does not make WordPress automatically lookup in the theme’s/plugin’s translation entries, and that the same text could exist in the translation entries of another text domain.