Compare commits

...

3 Commits

Author SHA1 Message Date
Clemens Schwaighofer
43b51895f0 Bug fixes in ACL\Login and DB\IO\Extended 2022-04-22 15:32:06 +09:00
Clemens Schwaighofer
d0e294ecf5 Fix Language encoding move documentation 2022-04-18 17:57:04 +09:00
Clemens Schwaighofer
3c35341e8b Bug fix in smarty block.t plugin
Equal instead of assign for plural text translate calls.

Update smarty tests with more detail checks of translations
2022-04-18 10:52:37 +09:00
6 changed files with 33 additions and 11 deletions

View File

@@ -160,6 +160,12 @@ _textdomain($domain);
_bindtextdomain($domain, $path); _bindtextdomain($domain, $path);
_bind_textdomain_codeset($domain, $encoding); _bind_textdomain_codeset($domain, $encoding);
echo "INPUT TEST $locale: " . $string . " => " . __($string) . "<br>"; echo "INPUT TEST $locale: " . $string . " => " . __($string) . "<br>";
$single_string = 'single';
$multi_string = 'multi';
for ($n = 0; $n <= 3; $n++) {
echo "MULTI TEST $n: " . $single_string . "/" . $multi_string . " => "
. _ngettext($single_string, $multi_string, $n) . "<br>";
}
$locale = 'en_US.UTF-8'; $locale = 'en_US.UTF-8';
_setlocale(LC_MESSAGES, $locale); _setlocale(LC_MESSAGES, $locale);
@@ -167,6 +173,12 @@ _textdomain($domain);
_bindtextdomain($domain, $path); _bindtextdomain($domain, $path);
_bind_textdomain_codeset($domain, $encoding); _bind_textdomain_codeset($domain, $encoding);
echo "INPUT TEST $locale: " . $string . " => " . __($string) . "<br>"; echo "INPUT TEST $locale: " . $string . " => " . __($string) . "<br>";
$single_string = 'single';
$multi_string = 'multi';
for ($n = 0; $n <= 3; $n++) {
echo "MULTI TEST $n: " . $single_string . "/" . $multi_string . " => "
. _ngettext($single_string, $multi_string, $n) . "<br>";
}
print "</body></html>"; print "</body></html>";

View File

@@ -14,7 +14,12 @@
<b>Translate Test with replace:</b><br> <b>Translate Test with replace:</b><br>
ORIGINAL: Original with string: %1 ({$replace})<br> ORIGINAL: Original with string: %1 ({$replace})<br>
TRANSLATED: {t 1=$replace}Original with string: %1{/t}<br> TRANSLATED: {t 1=$replace}Original with string: %1{/t}<br>
TRANSLATED (escape): {t escape=on 1=$replace}Original with string: %1{/t} TRANSLATED (escape): {t escape=on 1=$replace}Original with string: %1{/t}<br>
{capture assign="extra_title"}{t}INPUT TEST{/t}{/capture}
Capture test: {$extra_title}<br>
{section name=plural_test start=0 loop=3}
Plural test {$smarty.section.plural_test.index}: {t count=$smarty.section.plural_test.index plural="multi"}single{/t}<br>
{/section}
</div> </div>
<div> <div>
<b>Variable variables:</b><br> <b>Variable variables:</b><br>

View File

@@ -885,13 +885,13 @@ class Login
$this->acl['show_ea_extra'] = false; $this->acl['show_ea_extra'] = false;
} }
// set the default edit access // set the default edit access
$this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT']; $this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT'] ?? null;
// integrate the type acl list, but only for the keyword -> level // integrate the type acl list, but only for the keyword -> level
foreach ($this->default_acl_list as $level => $data) { foreach ($this->default_acl_list as $level => $data) {
$this->acl['min'][$data['type']] = $level; $this->acl['min'][$data['type']] = $level;
} }
// set the full acl list too // set the full acl list too
$this->acl['acl_list'] = $_SESSION['DEFAULT_ACL_LIST']; $this->acl['acl_list'] = $_SESSION['DEFAULT_ACL_LIST'] ?? [];
// debug // debug
// $this->debug('ACL', $this->print_ar($this->acl)); // $this->debug('ACL', $this->print_ar($this->acl));
} }
@@ -1453,7 +1453,8 @@ EOM;
* checks that the given edit access id is valid for this user * checks that the given edit access id is valid for this user
* @param int|null $edit_access_id edit access id to check * @param int|null $edit_access_id edit access id to check
* @return int|null same edit access id if ok * @return int|null same edit access id if ok
* or the default edit access id if given one is not valid * or the default edit access id
* if given one is not valid
*/ */
public function loginCheckEditAccessId(?int $edit_access_id): ?int public function loginCheckEditAccessId(?int $edit_access_id): ?int
{ {
@@ -1463,7 +1464,7 @@ EOM;
is_array($_SESSION['UNIT']) && is_array($_SESSION['UNIT']) &&
!array_key_exists($edit_access_id, $_SESSION['UNIT']) !array_key_exists($edit_access_id, $_SESSION['UNIT'])
) { ) {
return (int)$_SESSION['UNIT_DEFAULT']; return $_SESSION['UNIT_DEFAULT'] ?? null;
} else { } else {
return $edit_access_id; return $edit_access_id;
} }

View File

@@ -503,7 +503,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// max id, falls INSERT // max id, falls INSERT
$q = 'SELECT MAX(' . $this->pk_name . ') + 1 AS pk_id FROM ' . $this->table_name; $q = 'SELECT MAX(' . $this->pk_name . ') + 1 AS pk_id FROM ' . $this->table_name;
if (is_array($res = $this->dbReturnRow($q))) { if (is_array($res = $this->dbReturnRow($q))) {
$pk_id = $res['pkd_id']; $pk_id = $res['pk_id'];
} else { } else {
$pk_id = 1; $pk_id = 1;
} }

View File

@@ -5,7 +5,7 @@
* Language\Encoding::__mbMimeEncode -> Convert\MimeEncode::__mbMimeEncode * Language\Encoding::__mbMimeEncode -> Convert\MimeEncode::__mbMimeEncode
* Langauge\Encoding::checkConvertEncoding -> Check\Encoding::checkConvertEncoding * Langauge\Encoding::checkConvertEncoding -> Check\Encoding::checkConvertEncoding
* Langauge\Encoding::setErrorChar -> Check\Encoding::setErrorChar * Langauge\Encoding::setErrorChar -> Check\Encoding::setErrorChar
* Langauge\Encoding::getErrorChar -> Encoding::getErrorChar * Langauge\Encoding::getErrorChar -> Check\Encoding::getErrorChar
* Langauge\Encoding::convertEncoding -> Convert\Encoding::convertEncoding * Langauge\Encoding::convertEncoding -> Convert\Encoding::convertEncoding
*/ */

View File

@@ -57,14 +57,18 @@ function smarty_gettext_strarg($str/*, $varargs... */)
* - escape - sets escape mode: * - escape - sets escape mode:
* - 'html' for HTML escaping, this is the default. * - 'html' for HTML escaping, this is the default.
* - 'js' for javascript escaping. * - 'js' for javascript escaping.
* - 'url' for url escaping.
* - 'no'/'off'/0 - turns off escaping * - 'no'/'off'/0 - turns off escaping
* - plural - The plural version of the text (2nd parameter of ngettext()) * - plural - The plural version of the text (2nd parameter of ngettext())
* - count - The item count for plural mode (3rd parameter of ngettext()) * - count - The item count for plural mode (3rd parameter of ngettext())
* - domain - Textdomain to be used, default if skipped (dgettext() instead of gettext())
* - context - gettext context. reserved for future use.
*
*/ */
// cs modified: __ calls instead of direct gettext calls // cs modified: __ calls instead of direct gettext calls
function smarty_block_t($params, $text, $template, &$repeat) function smarty_block_t($params, $text)
{ {
if (!isset($text)) { if (!isset($text)) {
return $text; return $text;
@@ -122,15 +126,15 @@ function smarty_block_t($params, $text, $template, &$repeat)
} }
} elseif (isset($context)) { } elseif (isset($context)) {
if (is_callable('_npgettext')) { if (is_callable('_npgettext')) {
$text == _npgettext($context, $text, $plural, $count); $text = _npgettext($context, $text, $plural, $count);
}/* elseif (is_callable('npgettext')) { }/* elseif (is_callable('npgettext')) {
$text = npgettext($context, $text, $plural, $count); $text = npgettext($context, $text, $plural, $count);
} */ } */
} else { } else {
if (is_callable('_ngettext')) { if (is_callable('_ngettext')) {
$text == _ngettext($text, $plural, $count); $text = _ngettext($text, $plural, $count);
} elseif (is_callable('ngettext')) { } elseif (is_callable('ngettext')) {
$text == ngettext($text, $plural, $count); $text = ngettext($text, $plural, $count);
} }
} }
} else { // use normal } else { // use normal