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.

I am adding a list of suggested plugins to my theme using TGM Plugin Activation - https://github.com/thomasgriffin/TGM-Plugin-Activation/

However, when I run theme check, about 40 or so recommendations popped up because the plugin uses variables in translatable functions. I was able to remove about half of the problems by typing in my text domain instead of using the variable used by the plugin author. However, I need help rectifying the error below:

RECOMMENDED: Possible variable $instance found in translation function in class- tgm-plugin-activation.php. Translation function calls must NOT contain PHP variables.

Here's the code associated with the error:

$table_data[$i]['source'] = __( 'External Link', TGM_Plugin_Activation::$instance->domain );

I know that translation functions should look something like __('Item Name', 'text-domain'), but I am not sure what to do with the second part of the function:

TGM_Plugin_Activation::$instance->domain

How can I adjust this so that it will work properly with translations?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The translation strings not only get parsed during rendering (output on screen/in browser), but also by the GNU gettext parser. This one is not a PHP parser, so it can't fetch variables. This is the only part of a Theme or a Plugin, where you need to repeat yourself and add the plain string to every translation/gettext function call.

// Wrong:
__( 'External Link', TGM_Plugin_Activation::$instance->domain );

// Right:
__( 'External Link', 'your_textdomain' );

Just to clarify this: Both above mentioned calls will work with POEdit. The first just won't work, when Automattic/wp.org ever brings the automated translation tool that Mark Jaquith promised. And this is the part the "Theme Check"-Plugin nags about. You're perfectly fine ignoring the "RECOMMENDED" messages. As you can read on this post by M.Jaquith - read briefly, then move to comments - this is just what gets recommended by "official" sources/lead developers.

share|improve this answer
    
__( 'External Link', 'your_theme_textdomain' ); ... to be more precise –  Nabil Kadimi Jan 17 '13 at 15:22
    
@NabilKadimi There`s an edit button if you want to change the answer to be more clear and easier to understand. –  kaiser Jan 17 '13 at 15:44
1  
Thanks, that's how I handled the other variable. Accepted and upvoted. –  chowwy Jan 17 '13 at 17:04
add comment

Doesn't look like the TGM code is properly translatable. You should simply change all the places in that code in which translation functions are being called to use your theme's text domain.

share|improve this answer
    
In fact it is fully translatable, but not by the automated system that the wp.org repository ... imagines. –  kaiser Jan 15 '13 at 19:10
    
hmm, might have misunderstood something in that code. –  Mark Kaplun Jan 15 '13 at 20:35
    
It just doesn't come very clear in the question, that it's actually about the Theme Checker plugin complaining about the variable in it. –  kaiser Jan 15 '13 at 20:40
add comment

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.