Bug fix for translation class, DB IO connection error set fix
- The translation file reader did an isset on a set variable insetad of checking if the variable is zero and so never started the translation system - The DB IO connection not set was wrongly set. If the connection failed it is not TRUE and else FALSE. There is a new internal method getConnectionStatus to query this status it returns TRUE/FALSE depending if the connection failed - Update the l10n test page with proper translation tests - init OK - show current lang/file - translation test - switch language test
This commit is contained in:
@@ -95,6 +95,7 @@ return [
|
|||||||
'www/media',
|
'www/media',
|
||||||
],
|
],
|
||||||
'exclude_file_list' => [
|
'exclude_file_list' => [
|
||||||
|
// ignore all symlink files to edit
|
||||||
'www/admin/edit_access.php',
|
'www/admin/edit_access.php',
|
||||||
'www/admin/edit_groups.php',
|
'www/admin/edit_groups.php',
|
||||||
'www/admin/edit_languages.php',
|
'www/admin/edit_languages.php',
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#********************************************************************
|
# ********************************************************************
|
||||||
# AUTHOR: Clemens Schwaighofer
|
# AUTHOR: Clemens Schwaighofer
|
||||||
# CREATED: 2005/08/09
|
# CREATED: 2005/08/09
|
||||||
# SHORT DESCRIPTION:
|
# SHORT DESCRIPTION:
|
||||||
# Backned English Messages file for gettext
|
# Backned English Messages file for gettext
|
||||||
# to craete: msgfmt -o ja.mo messages_en.po
|
# to craete: msgfmt -o ja.mo messages_en.po
|
||||||
# HISTORY:
|
# HISTORY:
|
||||||
#********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -24,3 +24,6 @@ msgstr "Year"
|
|||||||
|
|
||||||
msgid "Month"
|
msgid "Month"
|
||||||
msgstr "Month"
|
msgstr "Month"
|
||||||
|
|
||||||
|
msgid "INPUT TEST"
|
||||||
|
msgstr "OUTPUT TEST EN"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#********************************************************************
|
# ********************************************************************
|
||||||
# AUTHOR: Clemens Schwaighofer
|
# AUTHOR: Clemens Schwaighofer
|
||||||
# CREATED: 2018/03/28
|
# CREATED: 2018/03/28
|
||||||
# SHORT DESCRIPTION:
|
# SHORT DESCRIPTION:
|
||||||
# Backend Japanese Messages file for gettext
|
# Backend Japanese Messages file for gettext
|
||||||
# to craete: msgfmt -o ja.mo messages_ja.po
|
# to craete: msgfmt -o ja.mo messages_ja.po
|
||||||
# HISTORY:
|
# HISTORY:
|
||||||
#********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -61,3 +61,6 @@ msgstr "土"
|
|||||||
|
|
||||||
msgid "Sun"
|
msgid "Sun"
|
||||||
msgstr "日"
|
msgstr "日"
|
||||||
|
|
||||||
|
msgid "INPUT TEST"
|
||||||
|
msgstr "OUTPUT TEST JA"
|
||||||
|
|||||||
@@ -5,13 +5,25 @@
|
|||||||
// namespace test
|
// namespace test
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
|
// init language
|
||||||
$lang = 'en_utf8';
|
$lang = 'en_utf8';
|
||||||
|
|
||||||
// admin class tests
|
// admin class tests
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
$l = new CoreLibs\Language\L10n($lang);
|
$l = new CoreLibs\Language\L10n($lang);
|
||||||
|
|
||||||
echo "OK<br>";
|
|
||||||
|
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
$string = 'INPUT TEST';
|
||||||
|
|
||||||
|
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||||
|
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||||
|
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||||
|
|
||||||
|
// switch to other language
|
||||||
|
$lang = 'ja_utf8';
|
||||||
|
$l->l10nReloadMOfile($lang);
|
||||||
|
|
||||||
|
echo "LANGUAGE SET: ".$l->__getLang()."<br>";
|
||||||
|
echo "LANGUAGE FILE: ".$l->__getMoFile()."<br>";
|
||||||
|
echo "INPUT TEST: ".$string." => ".$l->__($string)."<br>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
|||||||
$lang = 'ja_utf8';
|
$lang = 'ja_utf8';
|
||||||
$base = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
|
$base = new CoreLibs\Admin\Backend(DB_CONFIG, $lang);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
if ($base->getConnectionStatus()) {
|
||||||
|
die("Cannot connect to database");
|
||||||
|
}
|
||||||
|
|
||||||
print "Start time: ".$base->runningTime()."<br>";
|
print "Start time: ".$base->runningTime()."<br>";
|
||||||
print "ByteStringFormat: ".$base->ByteStringFormat(1234567.12)."<br>";
|
print "ByteStringFormat: ".$base->ByteStringFormat(1234567.12)."<br>";
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ $SITE_CONFIG = array (
|
|||||||
'debug_flag' => true,
|
'debug_flag' => true,
|
||||||
// site language
|
// site language
|
||||||
'site_lang' => 'en_utf8',
|
'site_lang' => 'en_utf8',
|
||||||
|
// enable/disable login override
|
||||||
|
'login_enabled' => true
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ DEFINE('DEFAULT_ENCODING', 'UTF-8');
|
|||||||
// below two can be defined here, but they should be
|
// below two can be defined here, but they should be
|
||||||
// defined in either the header file or the file itself
|
// defined in either the header file or the file itself
|
||||||
/************* LOGGING *******************/
|
/************* LOGGING *******************/
|
||||||
// DEFINE('LOG_FILE_ID', '');
|
DEFINE('LOG_FILE_ID', '');
|
||||||
|
|
||||||
/************* CLASS ERRORS *******************/
|
/************* CLASS ERRORS *******************/
|
||||||
// 0 = default all OFF
|
// 0 = default all OFF
|
||||||
@@ -220,7 +220,7 @@ if ((array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) && $_SERVE
|
|||||||
}
|
}
|
||||||
// define the db config set name, the db config and the db schema
|
// define the db config set name, the db config and the db schema
|
||||||
DEFINE('DB_CONFIG_NAME', $SITE_CONFIG[$HOST_NAME]['db_host']);
|
DEFINE('DB_CONFIG_NAME', $SITE_CONFIG[$HOST_NAME]['db_host']);
|
||||||
DEFINE('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME]);
|
DEFINE('DB_CONFIG', isset($DB_CONFIG[DB_CONFIG_NAME]) ? $DB_CONFIG[DB_CONFIG_NAME] : array ());
|
||||||
// DEFINE('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
|
// DEFINE('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
|
||||||
// DEFINE('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
|
// DEFINE('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
|
||||||
// override for login and global schemas
|
// override for login and global schemas
|
||||||
@@ -230,6 +230,7 @@ DEFINE('DB_CONFIG', $DB_CONFIG[DB_CONFIG_NAME]);
|
|||||||
DEFINE('TARGET', $SITE_CONFIG[$HOST_NAME]['location']);
|
DEFINE('TARGET', $SITE_CONFIG[$HOST_NAME]['location']);
|
||||||
DEFINE('DEBUG', $SITE_CONFIG[$HOST_NAME]['debug_flag']);
|
DEFINE('DEBUG', $SITE_CONFIG[$HOST_NAME]['debug_flag']);
|
||||||
DEFINE('SITE_LANG', $SITE_CONFIG[$HOST_NAME]['site_lang']);
|
DEFINE('SITE_LANG', $SITE_CONFIG[$HOST_NAME]['site_lang']);
|
||||||
|
DEFINE('LOGIN_ENABLED', $SITE_CONFIG[$HOST_NAME]['login_enabled']);
|
||||||
// paths
|
// paths
|
||||||
// DEFINE('CSV_PATH', $PATHS[TARGET]['csv_path']);
|
// DEFINE('CSV_PATH', $PATHS[TARGET]['csv_path']);
|
||||||
// DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']);
|
// DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']);
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
|
|
||||||
// File and Folder paths
|
// File and Folder paths
|
||||||
// ID is TARGET (first array element)
|
// ID is TARGET (first array element)
|
||||||
// $PATHS['test']['csv_path'] = '';
|
/*$PATHS = array (
|
||||||
// $PATHS['test']['perl_bin'] = '';
|
'test' => array (
|
||||||
// $PATHS['test']['redirect_url'] = '';
|
'csv_path' => '',
|
||||||
|
'perl_bin' => '',
|
||||||
|
'other_url' => '',
|
||||||
|
)
|
||||||
|
)*/
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -122,7 +122,7 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
|
|
||||||
// create db connection and init base class
|
// create db connection and init base class
|
||||||
parent::__construct($db_config, $set_control_flag);
|
parent::__construct($db_config, $set_control_flag);
|
||||||
if ($this->db_init_error === false) {
|
if ($this->db_init_error === true) {
|
||||||
echo 'Could not connect to DB<br>';
|
echo 'Could not connect to DB<br>';
|
||||||
// if I can't connect to the DB to auth exit hard. No access allowed
|
// if I can't connect to the DB to auth exit hard. No access allowed
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -376,18 +376,15 @@ class IO extends \CoreLibs\Basic
|
|||||||
// abort error
|
// abort error
|
||||||
$this->error_id = 10;
|
$this->error_id = 10;
|
||||||
$this->__dbError();
|
$this->__dbError();
|
||||||
$this->db_init_error = false;
|
$this->db_init_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect to DB
|
// connect to DB
|
||||||
if (!$this->__connectToDB()) {
|
if (!$this->__connectToDB()) {
|
||||||
$this->error_id = 16;
|
$this->error_id = 16;
|
||||||
$this->__dbError();
|
$this->__dbError();
|
||||||
$this->db_init_error = false;
|
$this->db_init_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// so we can check that we have a successful DB connection created
|
|
||||||
$this->db_init_error = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -897,6 +894,17 @@ class IO extends \CoreLibs\Basic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the db init error
|
||||||
|
* if failed to connect it is set to true
|
||||||
|
* else false
|
||||||
|
* @return bool connection failure status
|
||||||
|
*/
|
||||||
|
public function getConnectionStatus(): bool
|
||||||
|
{
|
||||||
|
return $this->db_init_error;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets new db schema
|
* sets new db schema
|
||||||
* @param string $db_schema schema name, if not given tries internal default db schema
|
* @param string $db_schema schema name, if not given tries internal default db schema
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class GetTextReader
|
|||||||
public function __construct($Reader, $enable_cache = true)
|
public function __construct($Reader, $enable_cache = true)
|
||||||
{
|
{
|
||||||
// If there isn't a StreamReader, turn on short circuit mode.
|
// If there isn't a StreamReader, turn on short circuit mode.
|
||||||
if (!$Reader || isset($Reader->error)) {
|
if (!$Reader || $Reader->error) {
|
||||||
$this->short_circuit = true;
|
$this->short_circuit = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user