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.

The second parameter in the translate function is optional, but I always see people use it and some don't.

So I want to know if I should use it or not and if yes, how I will use it later.

I asking this because I'm new to this, and I'm using e() and _() right now in my theme, and I'll learn how to translate it when I finish.

Thanks in advance

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Welcome to WPSE Peter,

The second argument is a translation domain. This is essentially where the translation for the first argument can be found. By default it checks the WordPress language folder - but if you are creating a custom theme or plug-in, you cannot rely on the translation for that string to be there (after all the WordPress language folders only contain translations for WordPress, not your plug-in/theme).

The setup is different for plug-ins, but to register a text domain for themes you use load_theme_textdomain:

add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
    load_theme_textdomain('my-unique-theme-domain', get_template_directory() . '/languages');
}

The first argument is the domain name, which is passed as the second argument in _e() and __(). The second is where the translation files can be found.

See Codex for _e() and __().

share|improve this answer
    
thank you very much –  Peter Mar 24 '12 at 11:14

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.