1
0
Fork 0

simplified pluralization logic

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-01-20 14:22:52 +05:30
Ursprung cdfd699491
Commit 7bc7c4013e
2 geänderte Dateien mit 7 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -3,14 +3,13 @@ import I18n from "I18n";
export default registerUnbound("char-counter", function(body, maxLength) { export default registerUnbound("char-counter", function(body, maxLength) {
let bodyLength = body ? body.length : 0; let bodyLength = body ? body.length : 0;
let length = maxLength || bodyLength;
let characterString = length == 1 ? 'wizard.character' : 'wizard.characters';
let finalString; let finalString;
if (maxLength) { if (maxLength) {
finalString = `<div class="body-length">${bodyLength} / ${maxLength} ${ I18n.t(characterString)}</div>`; finalString = `<div class="body-length">${bodyLength} / ${I18n.t('wizard.x_characters', { count: parseInt(maxLength) })}</div>`;
} else { } else {
finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`; finalString = `<div class="body-length">${I18n.t('wizard.x_characters', { count: parseInt(bodyLength) })}</div>`;
} }
return new Handlebars.SafeString(finalString); return new Handlebars.SafeString(finalString);
}); });

Datei anzeigen

@ -471,8 +471,9 @@ en:
requires_login: "You need to be logged in to access this wizard." requires_login: "You need to be logged in to access this wizard."
reset: "Reset this wizard." reset: "Reset this wizard."
step_not_permitted: "You're not permitted to view this step." step_not_permitted: "You're not permitted to view this step."
characters: "Characters" x_characters:
character: "Character" one: "%{count} Character"
other: "%{count} Characters"
wizard_composer: wizard_composer:
show_preview: "Preview Post" show_preview: "Preview Post"