PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > Script Installation

Reply
 
Thread Tools
Old 08-25-2004, 01:42 AM   #1
-ding-dong-
Green Mole
 
Join Date: Aug 2004
Posts: 6
Translation Problems

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;

}
?>
-ding-dong- is offline   Reply With Quote
Old 08-25-2004, 10:06 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. You can edit/add strings in the de-language.php file.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 08-26-2004, 03:34 AM   #3
-ding-dong-
Green Mole
 
Join Date: Aug 2004
Posts: 6
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?
-ding-dong- is offline   Reply With Quote
Old 08-26-2004, 09:02 AM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
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:
PHP Code:
// echo "\n\nPath not recognized!\n\n"; 
Also add a line after that to echo the $relative_script_path variable.
PHP Code:
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.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 08-27-2004, 05:32 AM   #5
-ding-dong-
Green Mole
 
Join Date: Aug 2004
Posts: 6
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- is offline   Reply With Quote
Old 08-27-2004, 05:49 AM   #6
-ding-dong-
Green Mole
 
Join Date: Aug 2004
Posts: 6
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?
-ding-dong- is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
template bug & translation suggestions bugmenot Bug Tracker 0 09-09-2005 12:55 AM
Russian (windows-1251) translation for PhpDig 1.8.7 AlexFree Mod Submissions 0 01-25-2005 04:05 AM
Russian (windows-1251) translation Voldar Mod Submissions 1 01-22-2005 07:41 AM
New translation (to catalan): ca-language (1.8.5) Xavi Mod Submissions 1 12-17-2004 04:57 PM


All times are GMT -8. The time now is 12:28 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.