SphereCommunity
differencing plural from singular words. - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: differencing plural from singular words. (/Thread-differencing-plural-from-singular-words)



differencing plural from singular words. - kn4tseb - 09-26-2014 07:02 AM

Hey guys, i'd like to know how do you manage to change a text in english for plural or singular: i.E 1 day - 2 days

ive seen the % operator in words but when i use a sysmessage this operator appears as part of the message. would you please help me with this?

thank you very much


RE: differencing plural from singular words. - Extreme - 09-26-2014 09:01 AM

Depends.. if you set the name of items like: Log%s
And if your item has amount = 1, when you click it will show Log and if amount is higher, will show Logs.
This only works for this situation and for pre-defined messages (sphere_msgs.scp)...

Otherwise, there is nothing (hardcoded) to differ plural from singular...

You can use <QVAL <AMOUNT>>1?s:> to add on messages you made having the right object amount checking of course...


RE: differencing plural from singular words. - kn4tseb - 09-26-2014 12:40 PM

i understand, thanks Extreme, maybe wont be bad to create a small function for it


RE: differencing plural from singular words. - Coruja - 09-26-2014 03:49 PM

you can use QVAL instead a new function only to parse the text

Code:
SYSMESSAGE <PLURAL Log,Logs>

[FUNCTION Plural]
IF (<AMOUNT> > 1)
  return <ARGV1>
ELSE
  return <ARGV0>
ENDIF

this can be replaced by a single line using QVAL

Code:
SYSMESSAGE <QVAL (<AMOUNT> > 1)? Logs:Log>