Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Can someone exactly explain this line for me?

share|improve this question

migrated from webmasters.stackexchange.com Jul 2 '12 at 16:19

This question came from our site for pro webmasters.

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
There are some language files in the theme. How does the arguement know to use them for only the 'Anyword'? –  Denny Mueller Jul 2 '12 at 15:17
    
I've updated my answer with a better part from the WP doc. –  j0k Jul 2 '12 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.