mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
feat: add user defined translations (#1756)
* feat: add user defined translations * add refetch key for translation (#1757) --------- Co-authored-by: Alex Christoffer Rasmussen <ac@omnivox.dk>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { copyFileSync, existsSync, writeFileSync } from 'fs';
|
||||
|
||||
import { ensureDirectory } from '../utils/fileManagement.js';
|
||||
import { defaultTranslation } from '../user/translations/bundledTranslations.js';
|
||||
|
||||
import { publicDir, publicFiles, srcFiles } from './index.js';
|
||||
|
||||
/**
|
||||
* ensures directories exist and populates translation
|
||||
*/
|
||||
export const populateTranslation = () => {
|
||||
ensureDirectory(publicDir.translationsDir);
|
||||
// if translations doesn't exist we want to use startup translation
|
||||
try {
|
||||
copyFileSync(srcFiles.translationReadme, publicFiles.translationReadme);
|
||||
if (!existsSync(publicFiles.translationsFile)) {
|
||||
// copy the startup translation only if user doesnt have one
|
||||
writeFileSync(publicFiles.translationsFile, defaultTranslation, { encoding: 'utf-8' });
|
||||
}
|
||||
} catch (_) {
|
||||
/* we do not handle this */
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user