fix plural
This commit is contained in:
parent
f47d62faad
commit
aee0557bb9
1 changed files with 9 additions and 6 deletions
|
@ -21,20 +21,23 @@ export const handleAttachments = (
|
||||||
|
|
||||||
let currentField = "";
|
let currentField = "";
|
||||||
const fields: APIEmbedField[] = [];
|
const fields: APIEmbedField[] = [];
|
||||||
let multiple = 0;
|
let multipleFields = 0;
|
||||||
|
let numberOfLinks = 0;
|
||||||
files.forEach((file, idx) => {
|
files.forEach((file, idx) => {
|
||||||
|
numberOfLinks++;
|
||||||
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
||||||
|
|
||||||
if (fieldValue.length > maxFieldValueLength) {
|
if (fieldValue.length > maxFieldValueLength) {
|
||||||
multiple = multiple === 0 && idx !== files.length - 1 ? 1 : multiple + 1;
|
multipleFields = multipleFields === 0 && idx !== files.length - 1 ? 1 : multipleFields + 1;
|
||||||
fields.push({
|
fields.push({
|
||||||
name:
|
name:
|
||||||
loc.get(
|
loc.get(
|
||||||
attachments.size > 1 && idx !== files.length - 1 ? "e_attachements" : "e_attachement",
|
attachments.size > 1 && numberOfLinks > 1 ? "e_attachements" : "e_attachement",
|
||||||
) + (multiple ? ` (${multiple})` : ""),
|
) + (multipleFields ? ` (${multipleFields})` : ""),
|
||||||
value: currentField,
|
value: currentField,
|
||||||
});
|
});
|
||||||
currentField = file;
|
currentField = file;
|
||||||
|
numberOfLinks = 0;
|
||||||
} else {
|
} else {
|
||||||
currentField = fieldValue;
|
currentField = fieldValue;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +46,8 @@ export const handleAttachments = (
|
||||||
if (currentField.length > 0) {
|
if (currentField.length > 0) {
|
||||||
fields.push({
|
fields.push({
|
||||||
name:
|
name:
|
||||||
loc.get(attachments.size > 1 && multiple ? "e_attachements" : "e_attachement") +
|
loc.get(attachments.size > 1 && numberOfLinks > 1 ? "e_attachements" : "e_attachement") +
|
||||||
(multiple ? ` (${multiple + 1})` : ""),
|
(multipleFields ? ` (${multipleFields + 1})` : ""),
|
||||||
value: currentField,
|
value: currentField,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue