View Single Post
05/09/14, 05:13 AM   #1
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Singular & plural form using the zo_strformat() function

Lua Code:
  1. pattern = "I have sold <<1>> <<1[items/item/items]>>."
  2.  
  3. msg = zo_strformat(pattern, num)

If num = 0
<<1>> is replaced by num and <<1[items/item/items]>> returns first from
msg = "I have sold 0 items"

if num = 1
<<1>> is replaced by num and <<1[items/item/items]>> returns second from
msg = "I have sold 1 item"

if num > 1
<<1>> is replaced by num (eg 5) and <<1[items/item/items]>> returns third from
msg = "I have sold 5 items"
  Reply With Quote