1

I've been studying some functions.php files to get my head around theme development, and I keep stumbling upon a reference to the theme name inside functions. Something like this:

<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
-------------------------------------------------------------------------------------^^

I find this odd, because the codex says the second variable of the_content should be a $stripteaser.

There are a lot of similar cases, for instance:

<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
-----------------------------------------^^

But also in functions.php

register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );
------------------------------------------------------------^^

Non of these seem to fulfil a variable position, so what do they do? What's the point of referring to the theme name?

0

In short: it's the so called »textdomain«.

The longer explanation: If you look accurate on your first example, you'll see, that this parameter is not the second parameter for the_content but for the Funktion __():

<?php 
the_content( 
    __( 
        'Continue reading <span class="meta-nav">&rarr;</span>', 
        'twentythirteen' 
    ) 
); 
?>

This function is part of the internationalisation (»I18n«) functions to make text translatable.

The textdomain acts as an identifier for translation files, which are typically stored in wp-content/languages for themes. So if you want to use this theme in German language for example, the language files would be named like twentythirteen-de_DE.mo and twentythirteen-de_DE.po.

de_DE is the so called »locale«, which is typically defined in the constant WPLANG which is (since WordPress version 4.0) stored in the option WPLANG.

.mo files are binary files, used by WordPress for the translation and .po files are editable (text) files to define translation for each string used in the source.

Some useful sources on internationalisation is the official documentation: http://codex.wordpress.org/I18n_for_WordPress_Developers

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.