mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
11 lines
426 B
TypeScript
11 lines
426 B
TypeScript
const pluralRules = new Intl.PluralRules("en-US");
|
|
|
|
export function pluralize(count: number, singular: string, plural?: string, skipCountInReturnedValue = false): string {
|
|
const countText = !skipCountInReturnedValue ? `${count} ` : "";
|
|
const pluralRule = pluralRules.select(count);
|
|
if (pluralRule === "one") {
|
|
return countText + singular;
|
|
}
|
|
return countText + (plural !== undefined ? plural : `${singular}s`);
|
|
}
|