mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +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,24 @@
|
||||
import { existsSync } from 'fs';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { defaultTranslation } from '../src/user/translations/bundledTranslation';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Script to write contents of default translation to translation.json
|
||||
*/
|
||||
async function bundleTranslation() {
|
||||
try {
|
||||
const translationDir = path.resolve(process.cwd(), 'src', 'user', 'translations');
|
||||
const translationsFile = path.resolve(translationDir, 'translations.json');
|
||||
|
||||
if (!existsSync(translationsFile)) {
|
||||
throw new Error('File does not exist');
|
||||
}
|
||||
|
||||
await writeFile(translationsFile, defaultTranslation, { encoding: 'utf8' });
|
||||
} catch (error) {
|
||||
console.error('Failed writing to translations file: ', error);
|
||||
}
|
||||
}
|
||||
|
||||
bundleTranslation();
|
||||
Reference in New Issue
Block a user