Forums / Cotonti / Core Labs / Archive / Dynamic Who's Online Labels

Making labels change accordingly.

TwistedGA
#1 2009-03-23 11:01
This really isn't anythign special, it's a very basic code change and may be completely useless to many people. I myself, and a neat freak and hate the (s) added to text that "might" become plural. It's cheap looking and with the amount of change needed, shouldn't be used IMHO. Below is an example of how the new method looks compared to the old.

Factory form, we get this:
1 member(s), 0 guest(s) :
Member1

With two users we get this:
2 member(s), 0 guest(s) :
Member1, Member2

The new method we have:
1 member, 0 guests :
Member1

With two users we have:
2 members, 0 guests :
Member1, Member2

To do this, you must edit two files. These files are:
system\lang\en\main.lang.php
system\common.php

What you need to do:
main.lang.php:
Change:
$L['com_member'] = 'member(s)';
$L['com_guest'] = 'guest(s)';
To:
$L['com_member'] = 'member';
$L['com_guest'] = 'guest';

common.php:
Change:
/* ======== Who's online part 2 ======== */
$out['whosonline'] = ($cfg['disablewhosonline']) ? '' : $sys['whosonline_reg_count'].' '.$L['com_members'].', '.$sys['whosonline_vis_count'].' '.$L['com_guests'];
To:
/* ======== Who's online part 2 ======== */
if($sys['whosonline_reg_count'] == 1){$Lmember = $L['com_member'];}
else{$Lmember .= "".$L['com_member']."s";}

if($sys['whosonline_vis_count'] == 1){$Lguest = $L['com_guest'];}
else{$Lguest .= "".$L['com_guest']."s";}

$out['whosonline'] = ($cfg['disablewhosonline']) ? '' : $sys['whosonline_reg_count'].' '.$Lmember.', '.$sys['whosonline_vis_count'].' '."$Lguest";

Dynamic Labels. Enjoy.
[color=#CC0000]Lazymod[/color] [color=#000000]Studios[/color]
Trustmaster
#2 2009-03-23 12:40
You forgot that English is not the only language on Earth. However, this is implemented in trunk with sed_declension() function, take a look.
May the Source be with you!
TwistedGA
#3 2009-03-23 12:52
Yea, I wasn't really sure on how is woudl cross to other languages, I figured if they coudl read my post, they coudl make changes accordingly.. Do you mind explaining to me what the "trunk" is, I downloaded and isntalled the files involved with this and took a look at the implementation, much better. Still curious about the "trunk" and why it seems to be more updated than 0.0.3. :) If you don't mind that is.
[color=#CC0000]Lazymod[/color] [color=#000000]Studios[/color]
Lombi
#4 2009-03-23 15:12
Trunk is always the most updated. Its SVN - a subversion.

Google it - it's the way developers contribute fixes to the package.

Also - This unfortunately doesnt port to other languages at all. What you could do is to have 4 language entries, but that doesnt fix issues that languages with duality (custom words for two things, rather than just one thing or many)
<a href="http://www.domenlo.com">Surreal Art</a>
GHengeveld
#5 2009-03-23 18:26
The only way to fix this is to use two language entries for each word, one for singular and one for the plural (i.e. member and members) and then switch between these two.
Kort
#6 2009-03-23 19:33
#Koradhil: Russian has three (1, 2...4, 0 & >5). I will soon post English translation of the sed_declension() manual.
SED.by - создание сайтов, разработка плагинов и тем для Котонти
Rhipnox
#7 2009-03-31 00:22
thanks