1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/tools/website/utils/processTranslations.ts

14 lines
715 B
TypeScript
Raw Normal View History

2022-11-22 20:16:57 +02:00
import { mkdirp, readFile, writeFile } from 'fs-extra';
import { dirname } from 'path';
import { Translations } from '../../utils/translation';
2022-11-22 20:16:57 +02:00
import applyTranslations from './applyTranslations';
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');
};