1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/tools/website/utils/processTranslations.ts
2023-10-11 10:17:46 +01:00

14 lines
715 B
TypeScript

import { mkdirp, readFile, writeFile } from 'fs-extra';
import { dirname } from 'path';
import { Translations } from '../../utils/translation';
import applyTranslations from './applyTranslations';
export default async (englishFilePath: string, translatedFilePath: string, languageCode: string, translations: Translations) => {
let content = await readFile(englishFilePath, 'utf8');
content = content.replace('<html lang="en-gb">', `<html lang="${languageCode}">`);
const translatedContent = await applyTranslations(content, languageCode, translations);
const translatedDirname = dirname(translatedFilePath);
await mkdirp(translatedDirname);
await writeFile(translatedFilePath, translatedContent, 'utf8');
};