mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
chore: Add test for duplicate locale keys
This commit is contained in:
27
test/sanity/no-duplicate-translation-keys.js
Normal file
27
test/sanity/no-duplicate-translation-keys.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
let glob = require('glob').sync;
|
||||
|
||||
describe('Locales files', () => {
|
||||
it.skip('do not contain duplicates of any keys', () => {
|
||||
let translationFiles = glob('./common/locales/en/*.json');
|
||||
|
||||
if (translationFiles.length === 0) {
|
||||
throw new Error('Could not find any files in ./common/locales/en/*.json');
|
||||
}
|
||||
|
||||
let keys = {};
|
||||
|
||||
translationFiles.forEach((file) => {
|
||||
let json = require(`../.${file}`); // eslint-disable-line global-require
|
||||
|
||||
Object.keys(json).forEach((key) => {
|
||||
if (keys[key]) {
|
||||
throw new Error(`${key} in ${file} already exists in ${keys[key]}.`);
|
||||
}
|
||||
|
||||
keys[key] = file;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user