aboutsummaryrefslogtreecommitdiffstats
path: root/src/i18n/apply-branding.ts
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-14 13:24:58 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-14 13:24:58 +0200
commitfe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e (patch)
tree10caa332d957421e982c7ddd0c94623d5d62314d /src/i18n/apply-branding.ts
parentchore: convert various JS to TS (#2062) (diff)
downloadferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.gz
ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.zst
ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.zip
chore: convert files to TS (#2066)
Diffstat (limited to 'src/i18n/apply-branding.ts')
-rw-r--r--src/i18n/apply-branding.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/i18n/apply-branding.ts b/src/i18n/apply-branding.ts
index 801a4a525..7943c099d 100644
--- a/src/i18n/apply-branding.ts
+++ b/src/i18n/apply-branding.ts
@@ -1,8 +1,8 @@
1/** 1/**
2 * Apply Ferdi branding to i18n translations 2 * Apply Ferdi branding to i18n translations
3 */ 3 */
4import fs from 'fs-extra'; 4import { readdirSync, readJson, writeJson } from 'fs-extra';
5import path from 'path'; 5import { join } from 'path';
6 6
7console.log('Applying Ferdi branding to translations...'); 7console.log('Applying Ferdi branding to translations...');
8 8
@@ -31,13 +31,13 @@ const replace = {
31 '!!!': '', 31 '!!!': '',
32}; 32};
33 33
34const locales = path.join(__dirname, 'locales'); 34const locales = join(__dirname, 'locales');
35const files = fs.readdirSync(locales); 35const files = readdirSync(locales);
36 36
37const replaceFind = Object.keys(replace); 37const replaceFind = Object.keys(replace);
38const replaceReplaceWith = Object.values(replace); 38const replaceReplaceWith = Object.values(replace);
39 39
40const replaceStr = (str, find, replaceWith) => { 40const replaceStr = (str: string, find: any[], replaceWith: string[]) => {
41 for (const [i, element] of find.entries()) { 41 for (const [i, element] of find.entries()) {
42 str = str.replace(new RegExp(element, 'gi'), replaceWith[i]); 42 str = str.replace(new RegExp(element, 'gi'), replaceWith[i]);
43 } 43 }
@@ -49,8 +49,8 @@ files.forEach(async file => {
49 if (ignoreFiles.has(file)) return; 49 if (ignoreFiles.has(file)) return;
50 50
51 // Read locale data 51 // Read locale data
52 const filePath = path.join(locales, file); 52 const filePath = join(locales, file);
53 const locale = await fs.readJson(filePath); 53 const locale = await readJson(filePath);
54 54
55 // Replace branding 55 // Replace branding
56 for (const key in locale) { 56 for (const key in locale) {
@@ -59,7 +59,7 @@ files.forEach(async file => {
59 } 59 }
60 } 60 }
61 61
62 await fs.writeJson(filePath, locale, { 62 await writeJson(filePath, locale, {
63 spaces: 2, 63 spaces: 2,
64 EOL: '\n', 64 EOL: '\n',
65 }); 65 });