mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
26 lines
718 B
JavaScript
26 lines
718 B
JavaScript
import { sync as glob } from 'glob';
|
|
|
|
describe('Locales files', () => {
|
|
it('do not contain duplicates of any keys', () => {
|
|
const translationFiles = glob('./website/common/locales/en/*.json');
|
|
|
|
if (translationFiles.length === 0) {
|
|
throw new Error('Could not find any files in ./website/common/locales/en/*.json');
|
|
}
|
|
|
|
const keys = {};
|
|
|
|
translationFiles.forEach(file => {
|
|
const json = require(`../.${file}`); // eslint-disable-line global-require, import/no-dynamic-require
|
|
|
|
Object.keys(json).forEach(key => {
|
|
if (keys[key]) {
|
|
throw new Error(`${key} in ${file} already exists in ${keys[key]}.`);
|
|
}
|
|
|
|
keys[key] = file;
|
|
});
|
|
});
|
|
});
|
|
});
|