Add helper which convert singular and plural.

This commit is contained in:
takezoe
2013-07-04 08:57:43 +09:00
parent bf4bd6e319
commit a326e4b095
3 changed files with 9 additions and 11 deletions

View File

@@ -18,6 +18,13 @@ object helpers {
*/
def date(date: Date): String = new SimpleDateFormat("yyyy-MM-dd").format(date)
/**
* Returns singular if count is 1, otherwise plural.
* If plural is not specified, returns singular + "s" as plural.
*/
def plural(count: Int, singular: String, plural: String = ""): String =
if(count == 1) singular else if(plural.isEmpty) singular + "s" else plural
/**
* Converts Markdown of Wiki pages to HTML.
*/