Internationalization and functions that use it

I’m building a new design into WP and so technically it is a theme, however it is only a design for one site and won’t be a theme anyone can use and hence I don’t want to bother with internationalization.

I have noticed WP makes use of internationalization in many functions by passing in the textdomain via functions such as..

Read More
_e( 'Featured', 'twentyeleven' );
esc_attr__( 'Permalink to %s', 'twentyeleven' )

How I have been told that it’s a bad idea to remove the textdomain as it may end up with odd results, but if I’m not bothering with internationalization what do I do?

Related posts

Leave a Reply

2 comments

  1. It is only a design for one site and won’t be a theme anyone can use and hence I don’t want to bother with internationalization.

    If the theme will only ever be used by you, internationalization isn’t a huge deal. Unless, of course, you will want to use a different language version of your theme in the future.

    However, it’s a good idea to get in the practice of always internationalizing your work. This way, if you ever change your mind about the theme (i.e. decide to release it later) you’ve already got the work done.

    Most often it’s just replacing a few lines of code:

    echo 'Some string';
    

    Becomes:

    _e( 'Some string', 'your-theme-textdomain' );
    

    And:

    return 'Some string';
    

    Becomes:

    __( 'Some string', 'your-theme-textdomain' );
    

    How I have been told that it’s a bad idea to remove the textdomain as it may end up with odd results.

    If you omit the textdomain from either __() or _e(), WordPress will assume you’re using the default textdomain that ships with core. And yes, some odd results will occur, but they aren’t too bad.

    For example, WordPress internally can translate “Post” and “Add New” but not “My super cool theme.” When your theme is translated, anywhere you passed in “Post” and “Add New” without a textdomain will be translated, but “My super cool theme” won’t.

    If I’m not bothering with internationalization what do I do?

    If you’re not going to worry about internationalization at all, then just don’t use __() or _e() at all and you won’t need to worry about textdomains either.

  2. If you’re not distributing it, then you don’t really have to bother with internationalizing it unless the client wants to make it translatable.

    In which case you don’t need to use _e() or __() or any other functions like those. And in that case, the textdomain doesn’t make any difference at all.

    Themes like twentyeleven and such are distributed to millions of people. Translating those is rather more important.