2022-04-25 18:48:42 +02:00
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
2022-02-26 19:38:29 +02:00
|
|
|
import {ProjectPath} from '../../src/backend/ProjectPath';
|
|
|
|
import {promises as fsp} from 'fs';
|
2022-03-30 22:18:02 +02:00
|
|
|
import * as path from 'path';
|
2022-04-25 18:48:42 +02:00
|
|
|
|
|
|
|
const chai = require('chai');
|
2022-02-26 19:38:29 +02:00
|
|
|
const {expect} = chai;
|
|
|
|
|
|
|
|
// to help WebStorm to handle the test cases
|
|
|
|
declare let describe: any;
|
|
|
|
|
|
|
|
|
|
|
|
describe('UI', () => {
|
|
|
|
|
|
|
|
|
|
|
|
it('translation should be listed in the angular.json', async () => {
|
|
|
|
const base = path.join('src', 'frontend', 'translate');
|
|
|
|
const translations = await fsp.readdir(path.join(ProjectPath.Root, base));
|
|
|
|
const angularConfig = require(path.join(ProjectPath.Root, 'angular.json'));
|
|
|
|
const knownTranslations = angularConfig.projects.pigallery2.i18n.locales;
|
|
|
|
|
|
|
|
|
|
|
|
for (const t of translations) {
|
2023-01-10 22:39:59 +02:00
|
|
|
let lang = t.substring(t.indexOf('.') + 1, t.length-4);
|
2022-02-26 19:38:29 +02:00
|
|
|
if (lang === 'en') {
|
|
|
|
continue; // no need to add 'en' as it is the default language.
|
|
|
|
}
|
2022-04-25 18:48:42 +02:00
|
|
|
if (lang === 'cn') {
|
|
|
|
lang = 'zh'; // zh county code is Chinese
|
|
|
|
}
|
2022-02-26 19:38:29 +02:00
|
|
|
const translationPath = path.join(base, t).replace(new RegExp('\\\\', 'g'), '/');
|
|
|
|
expect(knownTranslations[lang]).to.deep.equal({
|
|
|
|
baseHref: '',
|
|
|
|
translation: translationPath
|
|
|
|
}, translationPath + ' should be added to angular.json');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|