2022-11-22 20:16:57 +02:00
|
|
|
import { mkdirp, readFile, writeFile } from 'fs-extra';
|
|
|
|
import { dirname } from 'path';
|
2023-10-11 11:17:46 +02:00
|
|
|
import { Translations } from '../../utils/translation';
|
2022-11-22 20:16:57 +02:00
|
|
|
import applyTranslations from './applyTranslations';
|
|
|
|
|
2023-10-11 11:17:46 +02:00
|
|
|
export default async (englishFilePath: string, translatedFilePath: string, languageCode: string, translations: Translations) => {
|
2022-11-22 20:16:57 +02:00
|
|
|
let content = await readFile(englishFilePath, 'utf8');
|
|
|
|
content = content.replace('<html lang="en-gb">', `<html lang="${languageCode}">`);
|
2022-11-28 18:16:32 +02:00
|
|
|
const translatedContent = await applyTranslations(content, languageCode, translations);
|
2022-11-22 20:16:57 +02:00
|
|
|
const translatedDirname = dirname(translatedFilePath);
|
|
|
|
await mkdirp(translatedDirname);
|
|
|
|
await writeFile(translatedFilePath, translatedContent, 'utf8');
|
|
|
|
};
|