import type { IPowerduckSystemResources } from '../app/powerduck-system-resources'; import PowerduckState from '../app/powerduck-state'; export default class PluralizationHelper { /** * Gets the correct plural form of a resource based on the count. It uses the following rules: * - If count is 1, it uses the "Singular" form of the resource. * - If count is greater than 1 and less than 5, it uses the "2to4" form of the resource. * - If count is 0 or greater than or equal to 5, it uses the "5more" form of the resource. * @param count The count to determine the plural form. * @param resourceBase The base name of the resource, without the pluralization suffix (e.g., "File" for "FileSingular", "File2to4", "File5more"). * @param includeCount Whether to include the count in the returned string (e.g., "3 Files" vs "Files"). Defaults to true. * @returns The correctly pluralized resource string, optionally prefixed with the count. */ static getCorrectPlural ( count: number, resourceBase: string, includeCount?: boolean, ) { const countPart = includeCount != false ? (`${count} `) : ''; if (count == 1) { return countPart + PowerduckState.getResourceValue(`${resourceBase}Singular` as keyof IPowerduckSystemResources); } else if (count > 1 && count < 5) { return countPart + PowerduckState.getResourceValue(`${resourceBase}2to4` as keyof IPowerduckSystemResources); } else { return countPart + PowerduckState.getResourceValue(`${resourceBase}5more` as keyof IPowerduckSystemResources); } } }