Files
suwayomi-material-you-webui/src/components/util/helpers.ts
T

20 lines
765 B
TypeScript
Raw Normal View History

2022-11-09 18:09:15 +01:00
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// eslint-disable-next-line import/prefer-default-export
2023-02-06 10:06:33 +01:00
export const pluralize = (count: number, input: string | { one: string; many: string }) => {
2022-11-09 18:09:15 +01:00
if (typeof input === 'string') {
return `${input}${count === 1 ? '' : 's'}`;
}
return input[count === 1 ? 'one' : 'many'];
};
2022-11-21 01:33:21 +01:00
2023-02-06 10:06:33 +01:00
export const interpolate = (count: number, input: { one: string; many: string }) => {
2022-11-21 01:33:21 +01:00
const text = count === 1 ? input.one : input.many;
return text.replaceAll('%count%', count.toString());
};