PDA

View Full Version : Translation Problems


-ding-dong-
08-25-2004, 12:42 AM
Hi,

I have problems with untranslated Strings

W_begin
W_whole
W_part

in my HTML output if I use PHPDig in a smarty function.

Any ideas?

Thanks in advanced.

Here is the code ...

<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.search.php
* Type: function
* Name: search
* Purpose: Search with phpDig.
* -------------------------------------------------------------
*/
function smarty_function_search($params, &$smarty)
{
$relative_script_path = $smarty->phpdig_relative_script_path;
$phpdig_template = $smarty->phpdig_template;

$no_connect = 0;


if (is_file("$relative_script_path/includes/config.php")) {
require( "$relative_script_path/includes/config.php" );
}
else {
die("Cannot find config.php file.\n");
}

if (is_file("$relative_script_path/libs/search_function.php")) {
require( "$relative_script_path/libs/search_function.php" );
}
else {
die("Cannot find search_function.php file.\n");
}


// extract vars
extract(phpdigHttpVars(
array('query_string'=>'string',
'refine'=>'integer',
'refine_url'=>'string',
'site'=>'string', // set to integer later
'limite'=>'integer',
'option'=>'string',
'lim_start'=>'integer',
'browse'=>'integer',
'path'=>'string'
)
));

$rssdf = "";

$search_result = phpdigSearch($id_connect, $query_string, $option, $refine,
$refine_url, $lim_start, $limite, $browse,
$site, $path, $relative_script_path, $phpdig_template, $rssdf);

return;

}
?>

Charter
08-25-2004, 09:06 AM
Hi. You can edit/add strings in the de-language.php file.

-ding-dong-
08-26-2004, 02:34 AM
Hi Charter,

thanks for your help again :-)

I checked the lacalization folder and all languages are available. I notized furthermore that I only have the problem if I call config.php in a Smarty function. If I use it directly on a php web-page it works fine. Well, I know it might be hard to figure out where the Smarty influence is but maybe someone uses the Smarty Template engine and PHPDig together.

Could it be that I have problem with the relativ path? Is it possible to configure PHPDig in a "secure" way and set a absolute path at the beginning?

Charter
08-26-2004, 08:02 AM
It is important to keep the first if statement in the config file for security. For PhpDig mods, you need to make sure it is secure. If you have path problems with the config file, go to the config and uncomment the following:

// echo "\n\nPath not recognized!\n\n";

Also add a line after that to echo the $relative_script_path variable.

echo "<br><br>".$relative_script_path;

Comments are written in the config file for how to add another path to the if statement. Now I'm not sure if this is your problem or whether everything works except that strings do not get translated.

-ding-dong-
08-27-2004, 04:32 AM
Hi Charter,

I added you lines and figured out that the path is ok.

After debugging I got the following situation:

Language "en" is set und the file is there. No Problems.

//includes language file
if (is_file("$relative_script_path/locales/$phpdig_language-language.php")) {
include "$relative_script_path/locales/$phpdig_language-language.php";
}
elseif (is_file("$relative_script_path/locales/en-language.php")) {
include "$relative_script_path/locales/en-language.php";
}
else {
die("Unable to select language pack.\n");
}

The language file contains the requested strings. No problems.

$phpdig_mess = array (
'choose_temp' =>'Choose a template',
'select_site' =>'Select a site to search',
...
'w_begin' =>'and operator',
'w_whole' =>'exact phrase',
'w_part' =>'or operator',

BUT at the end in function

function phpdigMsg($string='') {
global $phpdig_mess;
if (isset($phpdig_mess[$string])) {
return nl2br($phpdig_mess[$string]);
}
else {
return ucfirst($string);
}
}

"$phpdig_mess" is NULL and I run into "ucfirst".

I tried to change the "include" to the "required" function to include the language.php but I got still the same wrong results.

Any ideas why $phpdig_mess is NULL after including the right file?

Thanks for your help.

-ding-dong-
08-27-2004, 04:49 AM
Some more information.

The scary thing in PHP (comming from Java) is that there is a intensive use of globals. I found globals with the same name (e.g. $path, $template) in phpbb, smarty or phpdig. Well, I use all :-( and how do I make sure that there are no overwrites. But this is a other story ...

So I figured out that $phpdig_mess is set properly in the smarty function "smarty_function_search". BUT it is NULL in "phpdigSearch" direct after calling the function.

It seams that we loos the "global" scope here.

Is there a way to get rid of all those globals and add them to the function calls. Well I meen I could add it by myself but I don't want to be incompatible with further releases.

Do you plan thinks like that? What do you think is the best way to handle that?