Is your theme using functions to include page sections (like get_sidebar(), get_header(), etc.)? If so, it’s a problem of scope; those functions don’t have explicit access to any variables defined outside of them.
There are a couple ways around this, you could use manual includes instead of functions in your template (for instance, instead of get_sidebar();, use require_once TEMPLATEPATH.'/sidebar.php';), and then put all of these variables at the top of your header file, or some other file that is common to all pages.
Probably the simplest thing to do, though, is to create a function in functions.php in your theme directory that spits out the text you need when you pass it what you want. Doing this, you’re guaranteed that you’ll have access to the variables at any place in your theme, and you don’t need to modify any of your theme’s files (except functions.php, of course).
For instance, you might make a function like this:
function echo_theme_text($type='', $language='')
{
/**
* Include the translation data here;
* copy and paste from translation.php, or do an include
*/
// Fail text; returned if no match found
$fail_text = 'text retrieval failed.';
// Get the right text variable
switch($type)
{
case 'home_teaser':
$text_variable = $_PAGE_HOME_TEASERTEXT;
break;
case 'home_body':
$text_variable = $_PAGE_HOME_BODYTEXT;
break;
/** Add however many blocks here as you have variables */
}
// In case no matches where found
if(!isset($text_variable)) echo $fail_text;
// Make sure language data exists before returning
if(isset($text_variable[$language]))
echo $text_variable[$language];
// Otherwise, fail out
else
echo $fail_text;
}
Then, in your theme, wherever you needed a translation, you could use <?php echo_theme_text('home_teaser','en'); ?>.
sojweb, thank you very much!
I tried the first suggestion which works perfectly, but on the other hand creates some redundant code (but I can live with that).
I will have a go at the second one as well and see if I can refine the method a bit (perhaps separate code and content).
Really appreciate your answer, thanks again.