pluralise -> pluralize

This commit is contained in:
thororen 2026-09-10 11:31:11 -04:00
parent ade73ebe1e
commit 2fbecccfe2
No known key found for this signature in database
7 changed files with 10 additions and 15 deletions

2
.rules
View file

@ -436,7 +436,7 @@ Deprecated: `@api/Themes`. `classNameFactory` re-export from `@api/Styles`.
- `Logger`. `new Logger(name)`. - `Logger`. `new Logger(name)`.
- `css`. `classNameFactory`, `classNameToSelector`. - `css`. `classNameFactory`, `classNameToSelector`.
- `misc`. `classes`, `sleep`, `isObject`, `isObjectEmpty`, `pluralise`, `parseUrl`, `identity`, `interpolateIfDefined`, `tryOrElse`, `isPluginDev`, `removeFromArray`. - `misc`. `classes`, `sleep`, `isObject`, `isObjectEmpty`, `pluralize`, `parseUrl`, `identity`, `interpolateIfDefined`, `tryOrElse`, `isPluginDev`, `removeFromArray`.
- `text`. `formatDuration`, `formatDurationMs`, `humanFriendlyJoin`, `makeCodeblock`, `toInlineCode`, `escapeRegExp`, `stripIndent`, `ZWSP`. - `text`. `formatDuration`, `formatDurationMs`, `humanFriendlyJoin`, `makeCodeblock`, `toInlineCode`, `escapeRegExp`, `stripIndent`, `ZWSP`.
- `react`. `useAwaiter`, `useForceUpdater`, `useIntersection`, `useTimer`, `useFixedTimer`, `useCleanupEffect`, `NoopComponent`, `isPrimitiveReactNode`. Re-exports `LazyComponent` from `lazyReact`. - `react`. `useAwaiter`, `useForceUpdater`, `useIntersection`, `useTimer`, `useFixedTimer`, `useCleanupEffect`, `NoopComponent`, `isPrimitiveReactNode`. Re-exports `LazyComponent` from `lazyReact`.
- `lazy`. `makeLazy`, `proxyLazy`. - `lazy`. `makeLazy`, `proxyLazy`.

View file

@ -13,7 +13,7 @@ import { Paragraph } from "@components/Paragraph";
import { EquicordDevsById, VencordDevsById } from "@utils/constants"; import { EquicordDevsById, VencordDevsById } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { fetchUserProfile } from "@utils/discord"; import { fetchUserProfile } from "@utils/discord";
import { pluralise } from "@utils/misc"; import { pluralize } from "@utils/misc";
import { RenderModalProps, User } from "@vencord/discord-types"; import { RenderModalProps, User } from "@vencord/discord-types";
import { Modal, openModal, showToast, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common"; import { Modal, openModal, showToast, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common";
@ -76,7 +76,7 @@ function ContributorModal({ user, modalProps }: { user: User; modalProps: Render
plugins.length plugins.length
? ( ? (
<Paragraph> <Paragraph>
{user.username} has {ContributedHyperLink} to {pluralise(plugins.length, "plugin")}! {user.username} has {ContributedHyperLink} to {pluralize(plugins.length, "plugin")}!
</Paragraph> </Paragraph>
) )
: ( : (

View file

@ -7,7 +7,7 @@
import { CloudDownloadIcon } from "@components/Icons"; import { CloudDownloadIcon } from "@components/Icons";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { pluralise } from "@utils/misc"; import { pluralize } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Message, MessageAttachment } from "@vencord/discord-types"; import { Message, MessageAttachment } from "@vencord/discord-types";
import { ChannelStore, showToast, Toasts } from "@webpack/common"; import { ChannelStore, showToast, Toasts } from "@webpack/common";
@ -55,7 +55,7 @@ async function downloadAll(attachments: MessageAttachment[]) {
const succeeded = attachments.length - failed; const succeeded = attachments.length - failed;
if (failed === 0) if (failed === 0)
showToast(`Downloaded ${pluralise(succeeded, "attachment")}.`, Toasts.Type.SUCCESS); showToast(`Downloaded ${pluralize(succeeded, "attachment")}.`, Toasts.Type.SUCCESS);
else else
showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, Toasts.Type.FAILURE); showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, Toasts.Type.FAILURE);
} }

View file

@ -14,7 +14,7 @@ import betterActivities from "@equicordplugins/betterActivities";
import showMeYourName from "@plugins/showMeYourName"; import showMeYourName from "@plugins/showMeYourName";
import { Devs, EquicordDevs } from "@utils/constants"; import { Devs, EquicordDevs } from "@utils/constants";
import { classNameFactory } from "@utils/css"; import { classNameFactory } from "@utils/css";
import { classes } from "@utils/misc"; import { classes, pluralize } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Activity, ApplicationStream, Channel, Message, OnlineStatus, User } from "@vencord/discord-types"; import { Activity, ApplicationStream, Channel, Message, OnlineStatus, User } from "@vencord/discord-types";
import { MessageFlags } from "@vencord/discord-types/enums"; import { MessageFlags } from "@vencord/discord-types/enums";
@ -115,10 +115,6 @@ function formatRelativeTime(timestamp: number): string {
return `${Math.max(1, minutes)}m`; return `${Math.max(1, minutes)}m`;
} }
function pluralize(count: number, singular: string, plural = singular + "s") {
return count === 1 ? `1 ${singular}` : `${count} ${plural}`;
}
function getMessageContent(message: Message): MessageContent | null { function getMessageContent(message: Message): MessageContent | null {
if (message.content) { if (message.content) {
if (/https?:\/\/(\S+\.gif|tenor\.com|giphy\.com|klipy\.com)/i.test(message.content)) { if (/https?:\/\/(\S+\.gif|tenor\.com|giphy\.com|klipy\.com)/i.test(message.content)) {

View file

@ -7,7 +7,7 @@
import { ChatBarButton } from "@api/ChatButtons"; import { ChatBarButton } from "@api/ChatButtons";
import { UploadIcon } from "@components/Icons"; import { UploadIcon } from "@components/Icons";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { pluralise } from "@utils/misc"; import { pluralize } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { Message } from "@vencord/discord-types"; import { Message } from "@vencord/discord-types";
import { MessageFlags, MessageType } from "@vencord/discord-types/enums"; import { MessageFlags, MessageType } from "@vencord/discord-types/enums";
@ -43,7 +43,7 @@ async function addAttachments(channelId: string, messageId: string, existingAtta
return; return;
} }
showToast(`You can only add ${pluralise(remaining, "more attachment")} to this message.`, Toasts.Type.FAILURE); showToast(`You can only add ${pluralize(remaining, "more attachment")} to this message.`, Toasts.Type.FAILURE);
return; return;
} }

View file

@ -5,7 +5,6 @@
*/ */
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles";
import { BaseText } from "@components/BaseText"; import { BaseText } from "@components/BaseText";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { ErrorCard } from "@components/ErrorCard"; import { ErrorCard } from "@components/ErrorCard";
@ -15,7 +14,7 @@ import { Devs, IS_MAC } from "@utils/constants";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { findByPropsLazy } from "@webpack";
import { ExperimentStore, React } from "@webpack/common"; import { React } from "@webpack/common";
const KbdStyles = findByPropsLazy("key", "combo"); const KbdStyles = findByPropsLazy("key", "combo");
const modKey = IS_MAC ? "cmd" : "ctrl"; const modKey = IS_MAC ? "cmd" : "ctrl";

View file

@ -86,7 +86,7 @@ export const shouldShowEquicordContributorBadge = (id: string) => isEquicordPlug
export const isAnyPluginDev = (id: string) => Object.hasOwn(VencordDevsById, id) || Object.hasOwn(EquicordDevsById, id); export const isAnyPluginDev = (id: string) => Object.hasOwn(VencordDevsById, id) || Object.hasOwn(EquicordDevsById, id);
export function pluralise(amount: number, singular: string, plural = singular + "s") { export function pluralize(amount: number, singular: string, plural = singular + "s") {
return amount === 1 ? `${amount} ${singular}` : `${amount} ${plural}`; return amount === 1 ? `${amount} ${singular}` : `${amount} ${plural}`;
} }