Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f085ccaa38 | ||
|
|
6c3c1a908d | ||
|
|
388b90913a | ||
|
|
07aea9d7b2 | ||
|
|
edcdbee523 |
14
4dev/bin/create_mo.sh
Executable file
14
4dev/bin/create_mo.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
base_folder='/var/www/html/developers/clemens/core_data/php_libraries/trunk/www/';
|
||||||
|
|
||||||
|
# locale gettext po to mo translator master
|
||||||
|
for file in $(ls -1 ${base_folder}../4dev/locale/*.po); do
|
||||||
|
file=$(basename $file .po);
|
||||||
|
echo "Translate language ${file}";
|
||||||
|
locale=$(echo "${file}" | cut -d "-" -f 1);
|
||||||
|
domain=$(echo "${file}" | cut -d "-" -f 2);
|
||||||
|
msgfmt -o ${base_folder}/includes/locale/${locale}/LC_MESSAGES/${domain}.mo ${base_folder}../4dev/locale/${locale}-${domain}.po;
|
||||||
|
done;
|
||||||
|
|
||||||
|
# __END__
|
||||||
@@ -1,4 +1,37 @@
|
|||||||
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/";
|
||||||
# -c phpunit.xml
|
# -c phpunit.xml
|
||||||
# --testdox
|
# --testdox
|
||||||
${base}www/vendor/bin/phpunit -c ${base}phpunit.xml ${base}4dev/tests/
|
# call with "t" to give verbose testdox output
|
||||||
|
# call with 7.3, 7.4, 8.0, 8.1 to force a certain php version
|
||||||
|
|
||||||
|
opt_testdox="";
|
||||||
|
if [ "${1}" = "t" ] || [ "${2}" = "t" ]; then
|
||||||
|
opt_testdox="--testdox";
|
||||||
|
fi;
|
||||||
|
php_bin="";
|
||||||
|
case "${1}" in
|
||||||
|
"7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
|
"7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
|
"8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
|
"8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
|
esac;
|
||||||
|
if [ -z "${php_bin}" ]; then
|
||||||
|
case "${2}" in
|
||||||
|
"7.3") php_bin="/usr/bin/php7.3 "; ;;
|
||||||
|
"7.4") php_bin="/usr/bin/php7.4 "; ;;
|
||||||
|
"8.0") php_bin="/usr/bin/php8.0 "; ;;
|
||||||
|
"8.1") php_bin="/usr/bin/php8.1 "; ;;
|
||||||
|
esac;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
phpunit_call="${php_bin}${base}www/vendor/bin/phpunit ${opt_testdox} -c ${base}phpunit.xml ${base}4dev/tests/";
|
||||||
|
|
||||||
|
${phpunit_call};
|
||||||
|
|
||||||
|
if [ ! -z "${php_bin}" ]; then
|
||||||
|
echo "CALLED WITH PHP: ${php_bin}"$(${php_bin} --version);
|
||||||
|
else
|
||||||
|
echo "Default PHP used: "$(php --version);
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# __END__
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
# AUTHOR: Clemens Schwaighofer
|
# AUTHOR: Clemens Schwaighofer
|
||||||
# CREATED: 2005/08/09
|
# CREATED: 2005/08/09
|
||||||
# SHORT DESCRIPTION:
|
# SHORT DESCRIPTION:
|
||||||
# Backned English Messages file for gettext
|
# Backend English Messages file for gettext
|
||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
|
||||||
# ********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
# ********************************************************************
|
||||||
|
# AUTHOR: Clemens Schwaighofer
|
||||||
|
# CREATED: 2005/08/09
|
||||||
|
# SHORT DESCRIPTION:
|
||||||
|
# Frontend English Messages file for gettext
|
||||||
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
# 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 <output.po> <input.mo>
|
|
||||||
# ********************************************************************/
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# to craete: msgfmt -o <output.po> <input.mo>
|
# ********************************************************************
|
||||||
|
# AUTHOR: Clemens Schwaighofer
|
||||||
|
# CREATED: 2005/08/09
|
||||||
|
# SHORT DESCRIPTION:
|
||||||
|
# Frontend Japanese Messages file for gettext
|
||||||
|
# ********************************************************************/
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -13,18 +13,73 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsACLLoginTest extends TestCase
|
final class CoreLibsACLLoginTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private static $db;
|
||||||
|
private static $log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* start DB conneciton, setup DB, etc
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pgsql')) {
|
if (!extension_loaded('pgsql')) {
|
||||||
$this->markTestSkipped(
|
self::markTestSkipped(
|
||||||
'The PgSQL extension is not available.'
|
'The PgSQL extension is not available.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// logger is always needed
|
||||||
|
// define basic connection set valid and one invalid
|
||||||
|
self::$log = new \CoreLibs\Debug\Logging([
|
||||||
|
// 'log_folder' => __DIR__ . DIRECTORY_SEPARATOR . 'log',
|
||||||
|
'log_folder' => DIRECTORY_SEPARATOR . 'tmp',
|
||||||
|
'file_id' => 'CoreLibs-ACL-Login-Test',
|
||||||
|
'debug_all' => false,
|
||||||
|
'echo_all' => false,
|
||||||
|
'print_all' => false,
|
||||||
|
]);
|
||||||
|
// if we do have pgsql, we need to create a test DB or check that one
|
||||||
|
// exists and clean the table to zero state
|
||||||
|
self::$db = new \CoreLibs\DB\IO(
|
||||||
|
[
|
||||||
|
'db_name' => 'corelibs_acl_login_test',
|
||||||
|
'db_user' => 'corelibs_acl_login_test',
|
||||||
|
'db_pass' => 'corelibs_acl_login_test',
|
||||||
|
'db_host' => 'localhost',
|
||||||
|
'db_port' => 5432,
|
||||||
|
'db_schema' => 'public',
|
||||||
|
'db_type' => 'pgsql',
|
||||||
|
'db_encoding' => '',
|
||||||
|
'db_ssl' => 'allow', // allow, disable, require, prefer
|
||||||
|
'db_debug' => true,
|
||||||
|
],
|
||||||
|
self::$log
|
||||||
|
);
|
||||||
|
if (!self::$db->dbGetConnectionStatus()) {
|
||||||
|
self::markTestSkipped(
|
||||||
|
'Cannot connect to valid Test DB for ACL\Login test.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
// check if they already exist, drop them
|
||||||
|
if ($db->dbShowTableMetaData('table_with_primary_key') !== false) {
|
||||||
|
$db->dbExec("DROP TABLE table_with_primary_key");
|
||||||
|
$db->dbExec("DROP TABLE table_without_primary_key");
|
||||||
|
$db->dbExec("DROP TABLE test_meta");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close db
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function tearDownAfterClass(): void
|
||||||
|
{
|
||||||
|
if (self::$db->dbGetConnectionStatus()) {
|
||||||
|
self::$db->dbClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
);
|
);
|
||||||
if (!$db->dbGetConnectionStatus()) {
|
if (!$db->dbGetConnectionStatus()) {
|
||||||
self::markTestSkipped(
|
self::markTestSkipped(
|
||||||
'Cannot connect to valid Test DB.'
|
'Cannot connect to valid Test DB for DB\IO test.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// check if they already exist, drop them
|
// check if they already exist, drop them
|
||||||
@@ -566,7 +566,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
public function testDbSetDebug(
|
public function testDbSetDebug(
|
||||||
string $connection,
|
string $connection,
|
||||||
?bool $set,
|
?bool $set,
|
||||||
bool $expected,
|
bool $expected
|
||||||
): void {
|
): void {
|
||||||
$db = new \CoreLibs\DB\IO(
|
$db = new \CoreLibs\DB\IO(
|
||||||
self::$db_config[$connection],
|
self::$db_config[$connection],
|
||||||
@@ -599,7 +599,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
public function testDbToggleDebug(
|
public function testDbToggleDebug(
|
||||||
string $connection,
|
string $connection,
|
||||||
?bool $toggle,
|
?bool $toggle,
|
||||||
bool $expected,
|
bool $expected
|
||||||
): void {
|
): void {
|
||||||
$db = new \CoreLibs\DB\IO(
|
$db = new \CoreLibs\DB\IO(
|
||||||
self::$db_config[$connection],
|
self::$db_config[$connection],
|
||||||
@@ -1734,7 +1734,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -1871,7 +1871,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -2034,7 +2034,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
array $cursor_ext_checks,
|
array $cursor_ext_checks,
|
||||||
string $warning,
|
string $warning,
|
||||||
string $error,
|
string $error,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -2356,7 +2356,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
string $error_execute,
|
string $error_execute,
|
||||||
string $expected_data_query,
|
string $expected_data_query,
|
||||||
array $expected_data,
|
array $expected_data,
|
||||||
string $insert_data,
|
string $insert_data
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
@@ -3010,7 +3010,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
string $insert,
|
string $insert,
|
||||||
?string $pk_name,
|
?string $pk_name,
|
||||||
string $table,
|
string $table,
|
||||||
string $primary_key,
|
string $primary_key
|
||||||
): void {
|
): void {
|
||||||
// self::$log->setLogLevelAll('debug', true);
|
// self::$log->setLogLevelAll('debug', true);
|
||||||
// self::$log->setLogLevelAll('print', true);
|
// self::$log->setLogLevelAll('print', true);
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ final class CoreLibsDebugLoggingTest extends TestCase
|
|||||||
bool $expected_debug,
|
bool $expected_debug,
|
||||||
string $expected_file,
|
string $expected_file,
|
||||||
string $expected_string_start,
|
string $expected_string_start,
|
||||||
string $expected_string_contains,
|
string $expected_string_contains
|
||||||
): void {
|
): void {
|
||||||
// must run with below matrix
|
// must run with below matrix
|
||||||
// level | debug | print | echo | debug() | printErrorMsg() | file
|
// level | debug | print | echo | debug() | printErrorMsg() | file
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase
|
|||||||
?string $path,
|
?string $path,
|
||||||
?string $SESSION_DEFAULT_LOCALE,
|
?string $SESSION_DEFAULT_LOCALE,
|
||||||
?string $SESSION_DEFAULT_CHARSET,
|
?string $SESSION_DEFAULT_CHARSET,
|
||||||
array $expected,
|
array $expected
|
||||||
): void {
|
): void {
|
||||||
$return_lang_settings = [];
|
$return_lang_settings = [];
|
||||||
global $_SESSION;
|
global $_SESSION;
|
||||||
|
|||||||
@@ -109,10 +109,11 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
// 2: encoding
|
// 2: encoding
|
||||||
// 3: path
|
// 3: path
|
||||||
// 4: locale expected
|
// 4: locale expected
|
||||||
// 5: domain exepcted
|
// 5: locale set expected
|
||||||
// 6: context (null for none)
|
// 6: domain exepcted
|
||||||
// 7: test string in
|
// 7: context (null for none)
|
||||||
// 8: test translated
|
// 8: test string in
|
||||||
|
// 9: test translated
|
||||||
// new style load
|
// new style load
|
||||||
'gettext load en' => [
|
'gettext load en' => [
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
@@ -120,6 +121,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
__DIR__ . 'includes/locale/',
|
__DIR__ . 'includes/locale/',
|
||||||
//
|
//
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
|
'en_US',
|
||||||
'frontend',
|
'frontend',
|
||||||
null,
|
null,
|
||||||
'Original',
|
'Original',
|
||||||
@@ -131,6 +133,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
__DIR__ . 'includes/locale/',
|
__DIR__ . 'includes/locale/',
|
||||||
//
|
//
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
|
'en_US',
|
||||||
'frontend',
|
'frontend',
|
||||||
'context',
|
'context',
|
||||||
'Original',
|
'Original',
|
||||||
@@ -142,6 +145,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
__DIR__ . 'includes/locale/',
|
__DIR__ . 'includes/locale/',
|
||||||
//
|
//
|
||||||
'ja_JP.UTF-8',
|
'ja_JP.UTF-8',
|
||||||
|
'ja_JP',
|
||||||
'admin',
|
'admin',
|
||||||
null,
|
null,
|
||||||
'Original',
|
'Original',
|
||||||
@@ -154,6 +158,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
'frontend',
|
'frontend',
|
||||||
//
|
//
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
|
'en_US',
|
||||||
'frontend',
|
'frontend',
|
||||||
'context',
|
'context',
|
||||||
'Original',
|
'Original',
|
||||||
@@ -167,6 +172,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
//
|
//
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
'',
|
||||||
null,
|
null,
|
||||||
'Original',
|
'Original',
|
||||||
'Original',
|
'Original',
|
||||||
@@ -185,6 +191,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
* @param string|null $domain
|
* @param string|null $domain
|
||||||
* @param string|null $path
|
* @param string|null $path
|
||||||
* @param string $locale_expected
|
* @param string $locale_expected
|
||||||
|
* @param string $locale_set_expected
|
||||||
* @param string $domain_expected
|
* @param string $domain_expected
|
||||||
* @param ?string $context
|
* @param ?string $context
|
||||||
* @param string $original
|
* @param string $original
|
||||||
@@ -196,10 +203,11 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
?string $domain,
|
?string $domain,
|
||||||
?string $path,
|
?string $path,
|
||||||
string $locale_expected,
|
string $locale_expected,
|
||||||
|
string $locale_set_expected,
|
||||||
string $domain_expected,
|
string $domain_expected,
|
||||||
?string $context,
|
?string $context,
|
||||||
string $original,
|
string $original,
|
||||||
string $translated,
|
string $translated
|
||||||
): void {
|
): void {
|
||||||
if ($locale === null) {
|
if ($locale === null) {
|
||||||
$l10n = new \CoreLibs\Language\L10n();
|
$l10n = new \CoreLibs\Language\L10n();
|
||||||
@@ -217,6 +225,11 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
$l10n->getLocale(),
|
$l10n->getLocale(),
|
||||||
'Locale assert failed'
|
'Locale assert failed'
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$locale_set_expected,
|
||||||
|
$l10n->getLocaleSet(),
|
||||||
|
'Locale set assert failed'
|
||||||
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$domain_expected,
|
$domain_expected,
|
||||||
$l10n->getDomain(),
|
$l10n->getDomain(),
|
||||||
@@ -255,15 +268,17 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
// 3: load error
|
// 3: load error
|
||||||
// 4: input string to translated
|
// 4: input string to translated
|
||||||
// 5: expected locale
|
// 5: expected locale
|
||||||
// 6: expected domain
|
// 6: expected locale set
|
||||||
// 7: expected translation
|
// 7: expected domain
|
||||||
// 8: change locale
|
// 8: expected translation
|
||||||
// 9: change domain
|
// 9: change locale
|
||||||
// 10: change path
|
// 10: change domain
|
||||||
// 11: change load error
|
// 11: change path
|
||||||
// 12: expected locale
|
// 12: change load error
|
||||||
// 13: expected domain
|
// 13: expected locale
|
||||||
// 14: expected translation
|
// 14: expected locale set
|
||||||
|
// 15: expected domain
|
||||||
|
// 16: expected translation
|
||||||
'load and change (en->ja)' => [
|
'load and change (en->ja)' => [
|
||||||
// set 0-2
|
// set 0-2
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
@@ -275,6 +290,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
'Original',
|
'Original',
|
||||||
// check setter 5-7
|
// check setter 5-7
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
|
'en_US',
|
||||||
'frontend',
|
'frontend',
|
||||||
'Translated frontend en_US',
|
'Translated frontend en_US',
|
||||||
// set new 8-10
|
// set new 8-10
|
||||||
@@ -285,6 +301,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
false,
|
false,
|
||||||
// check new setter 12-14
|
// check new setter 12-14
|
||||||
'ja_JP.UTF-8',
|
'ja_JP.UTF-8',
|
||||||
|
'ja_JP',
|
||||||
'frontend',
|
'frontend',
|
||||||
'Translated frontend ja_JP',
|
'Translated frontend ja_JP',
|
||||||
],
|
],
|
||||||
@@ -300,6 +317,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
// check setter 5-7
|
// check setter 5-7
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
'',
|
||||||
'Original',
|
'Original',
|
||||||
// set new 8-10
|
// set new 8-10
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
@@ -309,6 +327,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
false,
|
false,
|
||||||
// check new setter 12-14
|
// check new setter 12-14
|
||||||
'en_US.UTF-8',
|
'en_US.UTF-8',
|
||||||
|
'en_US',
|
||||||
'frontend',
|
'frontend',
|
||||||
'Translated frontend en_US',
|
'Translated frontend en_US',
|
||||||
]
|
]
|
||||||
@@ -329,12 +348,14 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
* @param bool $load_error
|
* @param bool $load_error
|
||||||
* @param string $original
|
* @param string $original
|
||||||
* @param string $locale_expected_a
|
* @param string $locale_expected_a
|
||||||
|
* @param string $locale_set_expected_a
|
||||||
* @param string $domain_expected_a
|
* @param string $domain_expected_a
|
||||||
* @param string $translated_a
|
* @param string $translated_a
|
||||||
* @param string|null $locale_new
|
* @param string|null $locale_new
|
||||||
* @param string|null $domain_new
|
* @param string|null $domain_new
|
||||||
* @param string|null $path_new
|
* @param string|null $path_new
|
||||||
* @param bool $load_error_new
|
* @param bool $load_error_new
|
||||||
|
* @param string $locale_set_expected_b
|
||||||
* @param string $locale_expected_b
|
* @param string $locale_expected_b
|
||||||
* @param string $domain_expected_b
|
* @param string $domain_expected_b
|
||||||
* @param string $translated_b
|
* @param string $translated_b
|
||||||
@@ -351,6 +372,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
string $original,
|
string $original,
|
||||||
// 5-7
|
// 5-7
|
||||||
string $locale_expected_a,
|
string $locale_expected_a,
|
||||||
|
string $locale_set_expected_a,
|
||||||
string $domain_expected_a,
|
string $domain_expected_a,
|
||||||
string $translated_a,
|
string $translated_a,
|
||||||
// 8-10
|
// 8-10
|
||||||
@@ -361,8 +383,9 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
bool $load_error_new,
|
bool $load_error_new,
|
||||||
// 12-14
|
// 12-14
|
||||||
string $locale_expected_b,
|
string $locale_expected_b,
|
||||||
|
string $locale_set_expected_b,
|
||||||
string $domain_expected_b,
|
string $domain_expected_b,
|
||||||
string $translated_b,
|
string $translated_b
|
||||||
): void {
|
): void {
|
||||||
if ($locale === null) {
|
if ($locale === null) {
|
||||||
$l10n = new \CoreLibs\Language\L10n();
|
$l10n = new \CoreLibs\Language\L10n();
|
||||||
@@ -384,6 +407,10 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
$locale_expected_a,
|
$locale_expected_a,
|
||||||
$l10n->getLocale(),
|
$l10n->getLocale(),
|
||||||
'Locale init assert failed'
|
'Locale init assert failed'
|
||||||
|
);$this->assertEquals(
|
||||||
|
$locale_set_expected_a,
|
||||||
|
$l10n->getLocaleSet(),
|
||||||
|
'Locale Set init assert failed'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$domain_expected_a,
|
$domain_expected_a,
|
||||||
@@ -435,6 +462,11 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
$l10n->getLocale(),
|
$l10n->getLocale(),
|
||||||
'Locale change assert failed'
|
'Locale change assert failed'
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$locale_set_expected_b,
|
||||||
|
$l10n->getLocaleSet(),
|
||||||
|
'Locale Set change assert failed'
|
||||||
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$domain_expected_b,
|
$domain_expected_b,
|
||||||
$l10n->getDomain(),
|
$l10n->getDomain(),
|
||||||
@@ -731,7 +763,7 @@ final class CoreLibsLanguageL10nTest extends TestCase
|
|||||||
string $type,
|
string $type,
|
||||||
string $var,
|
string $var,
|
||||||
string $value,
|
string $value,
|
||||||
string $expected,
|
string $expected
|
||||||
): void {
|
): void {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'global':
|
case 'global':
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace test;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class TemplateMethodsTest extends TestCase
|
|
||||||
{
|
|
||||||
public static function setUpBeforeClass(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function assertPreConditions(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOne(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
$this->assertTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTwo(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
$this->assertTrue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function assertPostConditions(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass(): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function onNotSuccessfulTest(\Throwable $t): void
|
|
||||||
{
|
|
||||||
fwrite(STDOUT, __METHOD__ . "\n");
|
|
||||||
throw $t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -68,6 +68,9 @@ print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "<br>";
|
|||||||
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
|
print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "<br>";
|
||||||
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
|
print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "<br>";
|
||||||
|
|
||||||
|
// get test
|
||||||
|
print "LOG FOLDER: " . $debug->getSetting('log_folder') . "<br>";
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "<br>";
|
print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "<br>";
|
||||||
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class DateTime
|
|||||||
4 => 'Thu',
|
4 => 'Thu',
|
||||||
5 => 'Fri',
|
5 => 'Fri',
|
||||||
6 => 'Sat',
|
6 => 'Sat',
|
||||||
7 => 'Sun'
|
7 => 'Sun',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const DAY_LONG = [
|
public const DAY_LONG = [
|
||||||
@@ -30,7 +30,7 @@ class DateTime
|
|||||||
4 => 'Thursday',
|
4 => 'Thursday',
|
||||||
5 => 'Friday',
|
5 => 'Friday',
|
||||||
6 => 'Saturday',
|
6 => 'Saturday',
|
||||||
7 => 'Sunday'
|
7 => 'Sunday',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const MONTH_LONG = [
|
public const MONTH_LONG = [
|
||||||
@@ -45,7 +45,7 @@ class DateTime
|
|||||||
9 => 'September',
|
9 => 'September',
|
||||||
10 => 'October',
|
10 => 'October',
|
||||||
11 => 'November',
|
11 => 'November',
|
||||||
12 => 'December'
|
12 => 'December',
|
||||||
];
|
];
|
||||||
/** @var array<int,string> */
|
/** @var array<int,string> */
|
||||||
public const MONTH_SHORT = [
|
public const MONTH_SHORT = [
|
||||||
@@ -60,7 +60,7 @@ class DateTime
|
|||||||
9 => 'Sep',
|
9 => 'Sep',
|
||||||
10 => 'Oct',
|
10 => 'Oct',
|
||||||
11 => 'Nov',
|
11 => 'Nov',
|
||||||
12 => 'Dec'
|
12 => 'Dec',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,7 +349,7 @@ class DateTime
|
|||||||
try {
|
try {
|
||||||
$start = new \DateTime($start_date);
|
$start = new \DateTime($start_date);
|
||||||
$end = new \DateTime($end_date);
|
$end = new \DateTime($end_date);
|
||||||
} catch (Exception) {
|
} catch (Exception $e) {
|
||||||
if ($return_named === true) {
|
if ($return_named === true) {
|
||||||
return [
|
return [
|
||||||
'overall' => 0,
|
'overall' => 0,
|
||||||
|
|||||||
@@ -401,10 +401,10 @@ class Logging
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary method to read all class variables for testing purpose
|
* Temporary method to read all class variables for testing purpose
|
||||||
* @param string $name
|
* @param string $name what variable to return
|
||||||
* @return mixed can be anything, bool, string, int, array
|
* @return mixed can be anything, bool, string, int, array
|
||||||
*/
|
*/
|
||||||
public function getSetting(string $name): mixed
|
public function getSetting(string $name) //:mixed DOES not work with PHP 7.4
|
||||||
{
|
{
|
||||||
// for debug purpose only
|
// for debug purpose only
|
||||||
return $this->{$name};
|
return $this->{$name};
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class L10n
|
|||||||
{
|
{
|
||||||
/** @var string the current locale */
|
/** @var string the current locale */
|
||||||
private $locale = '';
|
private $locale = '';
|
||||||
|
/** @var string the SET locale as WHERE the domain file is */
|
||||||
|
private $locale_set = '';
|
||||||
/** @var string the default selected/active domain */
|
/** @var string the default selected/active domain */
|
||||||
private $domain = '';
|
private $domain = '';
|
||||||
/** @var array<string,array<string,GetTextReader>> locale > domain = translator */
|
/** @var array<string,array<string,GetTextReader>> locale > domain = translator */
|
||||||
@@ -77,7 +79,7 @@ class L10n
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
string $locale = '',
|
string $locale = '',
|
||||||
string $domain = '',
|
string $domain = '',
|
||||||
string $path = '',
|
string $path = ''
|
||||||
) {
|
) {
|
||||||
// auto load language only if at least locale and domain is set
|
// auto load language only if at least locale and domain is set
|
||||||
if (!empty($locale) && !empty($domain)) {
|
if (!empty($locale) && !empty($domain)) {
|
||||||
@@ -141,6 +143,7 @@ class L10n
|
|||||||
// store old settings
|
// store old settings
|
||||||
$old_mofile = $this->mofile;
|
$old_mofile = $this->mofile;
|
||||||
$old_lang = $this->locale;
|
$old_lang = $this->locale;
|
||||||
|
$old_lang_set = $this->locale_set;
|
||||||
$old_domain = $this->domain;
|
$old_domain = $this->domain;
|
||||||
$old_base_locale_path = $this->base_locale_path;
|
$old_base_locale_path = $this->base_locale_path;
|
||||||
$old_base_content_path = $this->base_content_path;
|
$old_base_content_path = $this->base_content_path;
|
||||||
@@ -172,6 +175,7 @@ class L10n
|
|||||||
. $this->base_content_path
|
. $this->base_content_path
|
||||||
. $domain . '.mo';
|
. $domain . '.mo';
|
||||||
if (file_exists($this->mofile)) {
|
if (file_exists($this->mofile)) {
|
||||||
|
$this->locale_set = $_locale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,6 +206,7 @@ class L10n
|
|||||||
// else fall back to the old ones
|
// else fall back to the old ones
|
||||||
$this->mofile = $old_mofile;
|
$this->mofile = $old_mofile;
|
||||||
$this->locale = $old_lang;
|
$this->locale = $old_lang;
|
||||||
|
$this->locale_set = $old_lang_set;
|
||||||
$this->domain = $old_domain;
|
$this->domain = $old_domain;
|
||||||
$this->base_locale_path = $old_base_locale_path;
|
$this->base_locale_path = $old_base_locale_path;
|
||||||
$this->base_content_path = $old_base_content_path;
|
$this->base_content_path = $old_base_content_path;
|
||||||
@@ -454,7 +459,7 @@ class L10n
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get current set locale
|
* get current set locale (want locale)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -463,6 +468,16 @@ class L10n
|
|||||||
return $this->locale;
|
return $this->locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* current set locale where mo file is located
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLocaleSet(): string
|
||||||
|
{
|
||||||
|
return $this->locale_set;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get current set language
|
* get current set language
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class SmartyExtend extends \Smarty
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
public $lang;
|
public $lang;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
public $locale_set;
|
||||||
|
/** @var string */
|
||||||
public $lang_short;
|
public $lang_short;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $domain;
|
public $domain;
|
||||||
@@ -170,6 +172,7 @@ class SmartyExtend extends \Smarty
|
|||||||
// get first part from lang
|
// get first part from lang
|
||||||
$this->lang_short = explode('_', $locale['lang'])[0];
|
$this->lang_short = explode('_', $locale['lang'])[0];
|
||||||
$this->domain = $this->l10n->getDomain();
|
$this->domain = $this->l10n->getDomain();
|
||||||
|
$this->locale_set = $this->l10n->getLocaleSet();
|
||||||
$this->lang_dir = $this->l10n->getBaseLocalePath();
|
$this->lang_dir = $this->l10n->getBaseLocalePath();
|
||||||
|
|
||||||
// opt load functions so we can use legacy init for smarty run perhaps
|
// opt load functions so we can use legacy init for smarty run perhaps
|
||||||
@@ -312,16 +315,24 @@ class SmartyExtend extends \Smarty
|
|||||||
}
|
}
|
||||||
// javascript translate data as template for auto translate
|
// javascript translate data as template for auto translate
|
||||||
if (empty($this->TEMPLATE_TRANSLATE)) {
|
if (empty($this->TEMPLATE_TRANSLATE)) {
|
||||||
$this->TEMPLATE_TRANSLATE = 'jsTranslate_' . $this->lang . '.tpl';
|
$this->TEMPLATE_TRANSLATE = 'jsTranslate_'
|
||||||
|
. $this->locale_set . '.' . $this->encoding
|
||||||
|
. '.tpl';
|
||||||
} else {
|
} else {
|
||||||
// we assume we have some fixed set
|
// we assume we have some fixed set
|
||||||
// we must add _<$this->lang>
|
// we must add _<$this->lang>
|
||||||
// if .tpl, put before .tpl
|
// if .tpl, put before .tpl
|
||||||
// if not .tpl, add _<$this->lang>.tpl
|
// if not .tpl, add _<$this->lang>.tpl
|
||||||
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
|
if (strpos($this->TEMPLATE_TRANSLATE, '.tpl')) {
|
||||||
$this->TEMPLATE_TRANSLATE = str_replace('.tpl', '_' . $this->lang . '.tpl', $this->TEMPLATE_TRANSLATE);
|
$this->TEMPLATE_TRANSLATE = str_replace(
|
||||||
|
'.tpl',
|
||||||
|
'-' . $this->locale_set . '.' . $this->encoding . '.tpl',
|
||||||
|
$this->TEMPLATE_TRANSLATE
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->TEMPLATE_TRANSLATE .= '_' . $this->lang . '.tpl';
|
$this->TEMPLATE_TRANSLATE .= '_'
|
||||||
|
. $this->locale_set . '.' . $this->encoding
|
||||||
|
. '.tpl';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if we can't find it, dump it
|
// if we can't find it, dump it
|
||||||
|
|||||||
Reference in New Issue
Block a user