Help us shape the future of Go! Take the 2026 Go Developer Survey

english

package module
v0.0.0-...-dfc980f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2015 License: MIT Imports: 1 Imported by: 0

README

English

English is a Go library for pretty-printing values in English.

Install

go get github.com/bfontaine/english

Usage

  • english.Bool(...) returns "yes" for true and "no" for false
  • english.OrdinalLiteral(...) returns an ordinal literal, e.g. "1st" for 1, "123rd" for 123, etc.
  • english.Plural(word, count) returns word either as is or with an s appended if count is different than 1.

I only implemented the functions I needed; which is why there are only three of them for now.

Documentation

Overview

Package english provides utilities for pretty-printing values in English

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) string

Bool returns either "yes" (true) or "no" (false)

func OrdinalLiteral

func OrdinalLiteral(n int) string

OrdinalLiteral returns an ordinal version of the given number. E.g.: 1st, 2nd, 123rd, 4916th.

func Plural

func Plural(s string, n int) string

Plural is a simple utility which takes a word and a quantity, and returns the pluralized version of the word if necessary. It doesn’t support special cases (e.g. Plural("woman", 2) will return "womans") but makes code more readable in the general case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL