Skip to content

Commit 741734d

Browse files
Improve pluralisation
1 parent 9824ead commit 741734d

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

plugins/output/adapt/outputHelpers.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,12 @@ function validateCourse(data, cb) {
285285
let components = data.component;
286286

287287
if (typeof contentObjects === 'undefined') {
288-
let courseString = app.polyglot.t('app.course').charAt(0).toUpperCase() + app.polyglot.t('app.course').slice(1);
289-
errors += courseString + ' "' + data.course[0].title + '" ' + app.polyglot.t('app.doesnotcontain') + ' ' + app.polyglot.t('app.page') + 's\n';
288+
let courseString = app.polyglot.t('app.course');
289+
errors += app.polyglot.t('app.doesnotcontain', {
290+
type: courseString[0].toUpperCase() + courseString.slice(1),
291+
title: data.course[0].title,
292+
childType: app.polyglot.t('app.page', 0)
293+
}) + '\n';
290294
return cb(errors, false);
291295
}
292296

@@ -302,13 +306,17 @@ function validateCourse(data, cb) {
302306
function iterateThroughChildren(parents, children) {
303307
let errors = '';
304308
parents.forEach(parent => {
305-
let parentType = app.polyglot.t('app.' + parent._type).charAt(0).toUpperCase() + app.polyglot.t('app.' + parent._type).slice(1);
309+
let parentType = app.polyglot.t('app.' + parent._type, 1);
306310
let childType = app.polyglot.t('app.children');
307-
if (children[0] && children[0]._type) childType = app.polyglot.t('app.' + children[0]._type) + 's';
311+
if (children[0] && children[0]._type) childType = app.polyglot.t('app.' + children[0]._type, 0);
308312
let found = children.find(child => JSON.stringify(child._parentId) === JSON.stringify(parent._id));
309313

310314
if (typeof found === 'undefined') {
311-
errors += parentType + ' "' + parent.title + '" ' + app.polyglot.t('app.doesnotcontain') + ' ' + childType + '\n';
315+
errors += app.polyglot.t('app.doesnotcontain', {
316+
type: parentType[0].toUpperCase() + parentType.slice(1),
317+
title: parent.title,
318+
childType: childType
319+
}) + '\n';
312320
}
313321
});
314322
return errors;

routes/lang/en.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
"app.preview": "Preview course",
172172
"app.previewing": "Previewing...",
173173
"app.forcerebuild": "Force rebuild",
174-
"app.doesnotcontain": "does not contain any",
174+
"app.doesnotcontain": "%{type} '%{title}' does not contain any %{childType}",
175175
"app.children": "children",
176176
"app.editprofiletitle": "User profile",
177177
"app.editprofileinformation": "You can view and modify your user information below.",
@@ -396,10 +396,10 @@
396396
"app.editing": "Editing %{type}: %{text}",
397397
"app.course": "course",
398398
"app.menu": "menu",
399-
"app.page": "page",
400-
"app.article": "article",
401-
"app.block": "block",
402-
"app.component": "component",
399+
"app.page": "page |||| pages",
400+
"app.article": "article |||| articles",
401+
"app.block": "block |||| blocks",
402+
"app.component": "component |||| components",
403403
"app.addedDefault": "Add to new courses by default?",
404404
"app.errorloadconfig": "Failed to load configuration settings for %{course}",
405405
"app.errorloadfiles": "Failed to load content files",

0 commit comments

Comments
 (0)