Skip to content

Commit

Permalink
frontend: Check translations in pre commit hook instead of a test
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
  • Loading branch information
sniok committed Jul 5, 2024
1 parent de308b4 commit 965ef7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"build-typedoc": "typedoc",
"build-storybook": "storybook build -o ../docs/development/storybook",
"i18n": "i18next 'src/**/*.{ts,tsx}' -c ./src/i18n/i18next-parser.config.js",
"check-i18n": "i18next 'src/**/*.{ts,tsx}' -c ./src/i18n/i18next-parser.config.js --fail-on-update || { echo '\n\n[i18n] Some translations are missing or outdated. Run `npm run i18n` to update them.\n\n'; exit 1; }",
"tsc": "tsc",
"make-version": "node ./make-env.js"
},
Expand All @@ -134,7 +135,7 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "npm run check-i18n && lint-staged"
}
},
"lint-staged": {
Expand Down
17 changes: 0 additions & 17 deletions frontend/src/i18n/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { execSync } from 'child_process';
import { error } from 'console';
import fs from 'fs';
import * as glob from 'glob';

const path = require('node:path');
const allowlist = require('./allowlist.json');

const frontendDir = path.join(__dirname, '..', '..');

/*
* Description:
* This test will check for duplicate keys in the translation files and will fail if any are found.
Expand Down Expand Up @@ -120,17 +117,3 @@ describe('Test for non-intentional repeating translation keys', () => {
expect(result).toBe(true);
});
});

function getTranslationChanges() {
// Get uncommitted changes in the tracked translation files.
return execSync(
`git status -uno --porcelain ${frontendDir}/src/i18n/locales/*/*.json`
).toString();
}

describe('Forgotten translations', () => {
test('Check uncommitted translations', async () => {
execSync('npm run i18n', { cwd: frontendDir });
expect(getTranslationChanges()).toBe('');
});
});

0 comments on commit 965ef7c

Please sign in to comment.