jpgraph: Internal error: Chosen locale file for error messag

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
kond
Posts: 5
Joined: 03 Aug 2007, 10:59

jpgraph: Internal error: Chosen locale file for error messag

Post by kond »

Hi all,

I can not make jpgraph working with mantis.
Jpgraph works ok when called from my own php scripts.
It also works ok when called from jpgraph examples scripts.
But i can only see "red cross" in mantis.

When i called the graph itself
(like this: https://servername/summary_graph_byreso ... &token=184)
I got the following error:
Internal error: Chosen locale file for error messages does not exist.

After some investigations i still don't know how tomake it work with mantis.

I use mantis 1.0.8
php 5.2.1
jpgraph 2.1.4
apache 2.0
freebsd 6.2

here are define statements from jpg-config.inc.php:
DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/winfonts/");
DEFINE("CSIMCACHE_DIR","csimcache/");
DEFINE("CSIMCACHE_HTTP_DIR","csimcache/");
DEFINE('CHINESE_TTF_FONT','bkai00mp.ttf');
DEFINE("LANGUAGE_GREEK",false);
DEFINE("GREEK_FROM_WINDOWS",false);
DEFINE("LANGUAGE_CYRILLIC",true);
DEFINE("CYRILLIC_FROM_WINDOWS",true);
DEFINE('LANGUAGE_CHARSET','windows-1251');
DEFINE('MINCHO_TTF_FONT','ipam.ttf');
DEFINE('PMINCHO_TTF_FONT','ipamp.ttf');
DEFINE('GOTHIC_TTF_FONT','ipag.ttf');
DEFINE('PGOTHIC_TTF_FONT','ipagp.ttf');
DEFINE('ASSUME_EUCJP_ENCODING',false);
DEFINE('DEFAULT_ERR_LOCALE','en');
DEFINE("DEFAULT_GFORMAT","auto");
DEFINE("USE_CACHE",false);
DEFINE("READ_CACHE",false);
DEFINE("USE_IMAGE_ERROR_HANDLER",true);
DEFINE("CATCH_PHPERRMSG",true);
DEFINE("INSTALL_PHP_ERR_HANDLER",true);
DEFINE("USE_APPROX_COLORS",true);
DEFINE("ERR_DEPRECATED",true);
DEFINE("BRAND_TIMING",false);
DEFINE("BRAND_TIME_FORMAT","(%01.3fs)");
DEFINE("CACHE_FILE_GROUP","www");
DEFINE("CACHE_FILE_MOD",0664);
DEFINE("USE_BRESENHAM",false);
DEFINE("_CSIM_SPECIALFILE","_csim_special_");
DEFINE("_CSIM_DISPLAY","_jpg_csimd");
DEFINE("_IMG_HANDLER","__handle");

and here are jpgraph settings from mantis config_inc.php
$g_use_jpgraph = ON;
$g_jpgraph_path = '/usr/local/share/jpgraph/';
$g_graph_font = 'arial';

Please advise where to look for the cause of the problem?

Thanks in advance,
Nikolay.
vboctor
Site Admin
Posts: 1304
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Post by vboctor »

What language are you using? Try to test it with English as the current language.
Migrate your MantisBT to the MantisHub Cloud
kond
Posts: 5
Joined: 03 Aug 2007, 10:59

Post by kond »

I'm using russian language.
But i tried with english (as a language for the account) - result is the same.
And when i'm calling jpgraph from my own scripts - rusisan letters are shown ok.

Thanks and regards,
Nikolay.
kond
Posts: 5
Joined: 03 Aug 2007, 10:59

I solved the problem

Post by kond »

I solved the problem. Tha cause was as following:

There is an error handler (jpgraph_errhandler.inc.php) file in jpgraph direcory, which contains the following code:
// If the chosen locale doesn't exist try english
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
$__jpg_err_locale = 'en';
}

$file = 'lang/'.$__jpg_err_locale.'.inc.php';
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
die('Internal error: Chosen locale file for error messages does not exist.');
}

In my case jpgraph package was installed using freebsd "ports". I dont understatnd why it happened but there was no "lang" directory in my jpgraph installation.
I downloaded jpgraph source, and extracted "lang" directory into /usr/local/share/jpgraph, where jpgraph is installed.
After this there were no more "red cross" instead of graphs. Now i got jpgraph error message claiming that constant FF_BOOK is not defined.
I commented out corresponding line in graph_api.php and now graphs in mantis are ok.
My own scripts, calling jpgraph, were ok because there were no errors in those scripts.

So there were two problems:
1. undefined constant FF_BOOK in mantis code (graph_api.php)
2. abcense of lang/en.inc.php file in jpgraph installation.

Hope this information may be useful for other mantis/jpgraph users.

Thanks and regards,
Nikolay.
michelnacouzi
Posts: 1
Joined: 04 Jul 2009, 09:54

Re: jpgraph: Internal error: Chosen locale file for error messag

Post by michelnacouzi »

Hi all, I don't know what is Mantis, I was trying to use jpgraph 2 and was not working, I was using php5.0 then i installed php 5.2 and i still have a red cross instead of the graph. I did the following steps for it to work:
First: there is a bug in the jpgraph.php file. on approximately line 77, there is a definition for the variable TTF_DIR without checking if the variable was already defined. Therefore, you have to modify the following code as follows:

Initial code:

Code: Select all

if (!defined('MBTTF_DIR')) {
    if (strstr( PHP_OS, 'WIN') ) {
	$sroot = getenv('SystemRoot');
        if( empty($sroot) ) {
	    $t = new ErrMsgText();
	    $msg = $t->Get(12,$file,$lineno);
	    die($msg);
        }
	else {
	  define('TTF_DIR', $sroot.'/fonts/');
        }
    } else {
	define('MBTTF_DIR','/usr/share/fonts/ja/TrueType/');
    }
}
Modified code:

Code: Select all

if (!defined('MBTTF_DIR')) {
    if (strstr( PHP_OS, 'WIN') ) {
	$sroot = getenv('SystemRoot');
        if( empty($sroot) ) {
	    $t = new ErrMsgText();
	    $msg = $t->Get(12,$file,$lineno);
	    die($msg);
        }
	else {
		if (!defined('TTF_DIR')){
	  	define('TTF_DIR', $sroot.'/fonts/');}
        }
    } else {
	define('MBTTF_DIR','/usr/share/fonts/ja/TrueType/');
    }
}

If you changed the code, and you're still getting the red cross, remove all the line returns from the end of all the files in the src folder;
Post Reply