How does printf( __( ) ); work?

Today I work through a theme to get a better understanding of WordPress and templating.
I discovered this:

<?php 
printf( 
    __('Designed by %s', 'Anyword'), 
    '<a href="http://www.example.com">Blub</a>'
); 
?>

I know it shows “Designed by Blub” (Where Blub is linked)
But what does the __() mean or why is there a string insert? What for is the Anyword?

Read More

Can someone exactly explain this line for me?

Related posts

Leave a Reply

1 comment

  1. It’s used for translate text.

    The second argument is a kind of namespace (called domain here) to retrieve the translation (for example from a dedicated file or something else).

    So Anyword here, should be the guy behind the template, or the company or what ever that can be a domain/namespace.

    edit:

    The doc from wordpress give more explanation on how to internationalizing a plugin:


    Add this to the Plugin code to make sure the language file(s) are loaded:

    load_plugin_textdomain('your-unique-name', false, basename( dirname( __FILE__ ) ) . '/languages' );
    

    To fetch a string simply use __('String name','your-unique-name'); to return the translation or _e('String name','your-unique-name'); to echo the translation. Translations will then go into your plugin’s /languages folder.


    For your plugin/theme, the your-unique-name seems to be Anyword.