mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/10345] Return the language key when the key has an empty array
PHPBB3-10345
This commit is contained in:
parent
dd99675f72
commit
65e6ab5530
2 changed files with 10 additions and 0 deletions
|
@ -1862,6 +1862,11 @@ class user extends session
|
||||||
$args[0] = $lang;
|
$args[0] = $lang;
|
||||||
return call_user_func_array('sprintf', $args);
|
return call_user_func_array('sprintf', $args);
|
||||||
}
|
}
|
||||||
|
else if (sizeof($lang) == 0)
|
||||||
|
{
|
||||||
|
// If the language entry is an empty array, we just return the language key
|
||||||
|
return $args[0];
|
||||||
|
}
|
||||||
|
|
||||||
// It is an array... now handle different nullar/singular/plural forms
|
// It is an array... now handle different nullar/singular/plural forms
|
||||||
$key_found = false;
|
$key_found = false;
|
||||||
|
|
|
@ -38,6 +38,8 @@ class phpbb_user_lang_test extends phpbb_test_case
|
||||||
1 => '1 post', // 1.x
|
1 => '1 post', // 1.x
|
||||||
2 => '%1$.1f posts', // 0.x, 2+.x
|
2 => '%1$.1f posts', // 0.x, 2+.x
|
||||||
),
|
),
|
||||||
|
'ARRY_EMPTY' => array(
|
||||||
|
),
|
||||||
'dateformat' => array(
|
'dateformat' => array(
|
||||||
'AGO' => array(
|
'AGO' => array(
|
||||||
1 => '%d second',
|
1 => '%d second',
|
||||||
|
@ -69,6 +71,9 @@ class phpbb_user_lang_test extends phpbb_test_case
|
||||||
$this->assertEquals($user->lang('ARRY', 2), '2 posts');
|
$this->assertEquals($user->lang('ARRY', 2), '2 posts');
|
||||||
$this->assertEquals($user->lang('ARRY', 123), '123 posts');
|
$this->assertEquals($user->lang('ARRY', 123), '123 posts');
|
||||||
|
|
||||||
|
// Empty array returns the language key
|
||||||
|
$this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY');
|
||||||
|
|
||||||
// No 0 key defined
|
// No 0 key defined
|
||||||
$this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts');
|
$this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts');
|
||||||
$this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post');
|
$this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post');
|
||||||
|
|
Loading…
Add table
Reference in a new issue