Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/default/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ clinic.field.parent = Area
contact = Contact
contact.phone = Phone
contact.notes = Notes
contact.parent = Belongs to
contact.parent.external_id = Household external ID
contact.parent.name = Household name
contact.parent.parent.contact.name = CHV Name
Expand Down
496 changes: 496 additions & 0 deletions config/default/translations/messages-es.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/default/translations/messages-fr.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/default/translations/messages-ne.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/default/translations/messages-sw.properties

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion config/demo/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ clinic.field.parent = Area
contact = Contact
contact.phone = Phone
contact.notes = Notes
contact.parent = Belongs to
contact.parent.external_id = Household external ID
contact.parent.name = Household name
contact.parent.parent.contact.name = CHV Name
Expand Down
496 changes: 496 additions & 0 deletions config/demo/translations/messages-es.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/demo/translations/messages-fr.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/demo/translations/messages-ne.properties

Large diffs are not rendered by default.

496 changes: 496 additions & 0 deletions config/demo/translations/messages-sw.properties

Large diffs are not rendered by default.

41 changes: 34 additions & 7 deletions scripts/ci/lint-translations.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
const { checkTranslations, TranslationException } = require('@medic/translation-checker');

const SUPPORTED_LANGUAGES = [ 'en', 'es', 'fr', 'ne', 'sw' ];
const TRANSLATION_DIR = `${__dirname}/../../api/resources/translations`;
const TRANSLATION_OPTIONS = {
const API_TRANSLATION_DIR = `${__dirname}/../../api/resources/translations`;
const CONFIG_TRANSLATION_DIRS = [
`${__dirname}/../../config/default/translations`,
`${__dirname}/../../config/demo/translations`,
];
const API_OPTIONS = {
checkPlaceholders: true,
checkEmpties: true,
checkMessageformat: true,
checkMissing: true,
languages: SUPPORTED_LANGUAGES
};
const CONFIG_OPTIONS = {
checkPlaceholders: true,
checkEmpties: false,
checkMessageformat: true,
checkMissing: true,
languages: SUPPORTED_LANGUAGES
};

const handleError = (e) => {
if (e instanceof TranslationException && !!e.errors) {
Expand All @@ -22,14 +33,30 @@ const handleError = (e) => {
};

const run = async () => {
let failed = false;

try {
const files = await checkTranslations(TRANSLATION_DIR, TRANSLATION_OPTIONS);
console.log(`Files checked: ${files}`);
console.log('Linting translation files passed');
const files = await checkTranslations(API_TRANSLATION_DIR, API_OPTIONS);
console.log(`API files checked: ${files}`);
} catch (e) {
const exitCode = handleError(e);
process.exit(exitCode);
handleError(e);
failed = true;
}

for (const dir of CONFIG_TRANSLATION_DIRS) {
try {
const files = await checkTranslations(dir, CONFIG_OPTIONS);
console.log(`Config files checked (${dir.split('/').slice(-3, -1).join('/')}): ${files}`);
} catch (e) {
handleError(e);
failed = true;
}
}

if (failed) {
process.exit(1);
}
console.log('Linting translation files passed');
};

console.log('Linting translation files...');
Expand Down