1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/packages/tools/website/utils/processTranslations.ts
2022-11-28 17:18:15 +01:00

13 lines
669 B
TypeScript

import { mkdirp, readFile, writeFile } from 'fs-extra';
import { dirname } from 'path';
import applyTranslations from './applyTranslations';
export default async (englishFilePath: string, translatedFilePath: string, languageCode: string, translations: Record<string, string>) => {
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');
};