plrl

package module
v0.0.0-...-4bd6e64 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: AGPL-3.0 Imports: 0 Imported by: 1

README

plrl

Simple Go functions for handling language plurals.

Go Reference go report card

Example

package main

import (
	"fmt"
	"github.com/speedyhoon/plrl"
)

func main() {
	want := 4
	fmt.Printf("At least %d item%s required.\n", want, plrl.Any(want, " is", "s are"))
	want = 1
	fmt.Printf("At least %d item%s required.\n", want, plrl.Any(want, " is", "s are"))
	days := 5
	fmt.Printf("%d day%s\n", days, plrl.S(days))
	days = -1
	fmt.Printf("%d day%s\n", days, plrl.S(days))
}

Output

At least 4 items are required.
At least 1 item is required.
5 days
-1 day

Documentation

Overview

Package plrl provides functions for handling language plurals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(length int, single, multiple string) string

Any returns string `single` when length is 1 or -1, otherwise returns `multiple`.

func Many

func Many(length int, single, multiple string) string

Many returns string `single` when length is 1 or -1, otherwise returns `multiple`, or an "s" if `multiple` is empty.

func S

func S(length int) string

S returns an "s" when length is not 1 or -1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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