What is the purpose of an extra file for translation?

What code is required to put in functions.php in order to make the theme translation ready?

The TwentyEleven theme has only following line:

load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );

But in many tutorials they have mentioned to add following:

load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
$locale = get_locale();
    $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    if ( is_readable( $locale_file ) )
        require_once( $locale_file );

Is the second part required to add in the functions.php file to make it translation ready? If it is, why the TwentyEleven theme does not have it?

1 Answer
1

The second part is not required, it just loads a PHP file with language specific functions.

Examples

  • In some countries/regions/religions it is not allowed to use capital letters in a word for anything else than the name of some god. In these cases you probably want to remove the WordPress to WordPress filter.

  • Some languages (Chinese) do not use spaces (in a predictable manner). If you use a function to set the excerpt length by words you will probably fail. In a language specific file you can disable that excerpt filter.

  • Different languages need different amounts of space, vertically and horizontally. See the very helpful article Text size in translation.
    The English word views is three times as long in Italian: visualizzazioni. That’s one of the reasons to test your layout not just in an extremely compact language like English. Thai for example takes more vertical space – you may have to adjust a grid layout with some extra rules (think <input size> and CSS of course).

Leave a Comment