24 Hour Activity Stats

Array support for all language variables - 24 Hour Activity Stats

Array support for all language variables

by tlem » Fri May 11, 2018 11:16 am

Hello. Would it be possible to upgrade this extension to support arrays for each variable in the language file?

In the last version, you take care about singular and plural for BOTS_24HOUR_TOTAL, GUEST_ONLINE_24 and TOTAL_24HOUR_USERS but the others variables can be singular or plural, like 24HOUR_TOPICS, 24HOUR_POSTS, 24HOUR_USERS, NO_ONLINE_BOTS, and in fact, all others. ^^

We can solve that like this :

Code: Select all

	'24HOUR_TOPICS'			=> 'New topic(s) %d',
	'24HOUR_POSTS'			=> 'New post(s) %d',
	'24HOUR_USERS'			=> 'New user(s) %d',
	'NO_ONLINE_BOTS'		=> 'No Bot(s) active',
but sometimes the singular and plural word is not the same, like for :

Code: Select all

	'TOTAL_24HOUR_USERS'	=> array(
		1 => 'In total there was %d user :: ',
		2 => 'In total there were %d users :: ',
	),

I tried to change :

Code: Select all

	'24HOUR_POSTS'			=> 'New post(s) %d',
by

Code: Select all

	'24HOUR_POSTS'	=> array(
		1 => 'Nouveau message %d',
		2 => 'Nouveaux messages %d',
	),
but it doesn't work.
User avatar
tlem
Registered User
Posts: 109
Joined: Sun Jan 24, 2016 4:47 pm
Location: Bordeaux (France)
Name: Thierry
Contact:

Re: Array support for all language variables

by RMcGirr83 » Fri May 11, 2018 11:31 am

Did you purge the cache after making that change?
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Array support for all language variables

by tlem » Fri May 11, 2018 1:02 pm

No, I don't do that. I thought that the update by "Upload Extension" did it.

I just test it, and it doesn't work even if I purge the cache.
It seems that it take always the last element of the array !!!

Thank you very much for your answer.
User avatar
tlem
Registered User
Posts: 109
Joined: Sun Jan 24, 2016 4:47 pm
Location: Bordeaux (France)
Name: Thierry
Contact:

Re: Array support for all language variables

by RMcGirr83 » Fri May 11, 2018 1:57 pm

No idea phpbb should recognize the array without touching anything extra in the code
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Array support for all language variables

by tlem » Fri May 11, 2018 9:05 pm

I have trying this :

Code: Select all

<?php

/**
*
*
* @package - Activity 24 hours
* @copyright (c) 2015 RMcGirr83
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

if (!defined('IN_PHPBB'))
{
	exit;
}

if (empty($lang) || !is_array($lang))
{
	$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
// Some characters you may want to copy&paste:
// ’ » “ ” …

$lang = array_merge($lang, array(
	'BOTS_24HOUR_TOTAL'	=> array(
		1 => '%d bot',
		2 => '%d bots',
	),
	'USERS_24HOUR_TOTAL' => array(
		1 => '%d user registered,',
		2 => '%d users registered,',
	),
	'HIDDEN_24HOUR_TOTAL' => array(
		1 => ' %d hidden user, ',
		2 => ' %d hidden users, ',
	),
	'GUEST_ONLINE_24'		=> array(
		1 => ' and %d guest',
		2 => ' and %d guests',
	),
	'LAST_24_HOURS'	=> ' active over the last 24 hours',
	'24HOUR_TOPICS'			=> array(
		1 => 'New topic %d',
		2 => 'New topics %d',
	),
	'24HOUR_POSTS'			=> array(
		1 => 'New post %d',
		2 => 'New posts %d',
	),
	'24HOUR_USERS'			=> array(
		1 => 'New user %d',
		2 => 'New users %d',
	),
	'NO_ONLINE_BOTS'		=> 'No Bots active',
	'TWENTYFOURHOUR_STATS'	=> 'Activity over the last 24 hours',
	'TOTAL_24HOUR_USERS'	=> array(
		1 => 'In total there was %d user :: ',
		2 => 'In total there were %d users :: ',
	),
));
But it seems not working (except for hidden user) :
Capture.JPG
Did I miss something?
User avatar
tlem
Registered User
Posts: 109
Joined: Sun Jan 24, 2016 4:47 pm
Location: Bordeaux (France)
Name: Thierry
Contact:

Re: Array support for all language variables

by RMcGirr83 » Sat May 12, 2018 10:35 pm

Did you look in the translations topic for the extension? I'm not seeing where there is an issue looking at your screen capture.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Array support for all language variables

by tlem » Sat May 12, 2018 10:44 pm

Hi RMcGirr83.
According to the language file above, the first line is wrong
- "New posts 3 * New Topics 1 * New Users 1"
should be
- "New posts 3 * New Topic 1 * New User 1"
because only one new topic and one new user.
User avatar
tlem
Registered User
Posts: 109
Joined: Sun Jan 24, 2016 4:47 pm
Location: Bordeaux (France)
Name: Thierry
Contact:

Re: Array support for all language variables

by RMcGirr83 » Sun May 13, 2018 10:29 am

I don't agree. The number doesn't dictate the plural use or not.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Array support for all language variables

by tlem » Sun May 13, 2018 11:16 am

In English probably not although you did it for BOTS_24HOUR_TOTAL, GUEST_ONLINE_24 and TOTAL_24HOUR_USERS.
But in other languages it may be necessary to be able to handle that.

I thought it would be easier to handle that, since it seems more complex than it seems, it's enough to adapt.
Thanks anyway for spending time answering me. I offer you a beer to thank you. ;)

Best regards
Thierry
User avatar
tlem
Registered User
Posts: 109
Joined: Sun Jan 24, 2016 4:47 pm
Location: Bordeaux (France)
Name: Thierry
Contact: