diff options
author | 2021-10-14 13:24:58 +0200 | |
---|---|---|
committer | 2021-10-14 13:24:58 +0200 | |
commit | fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e (patch) | |
tree | 10caa332d957421e982c7ddd0c94623d5d62314d /src/i18n | |
parent | chore: convert various JS to TS (#2062) (diff) | |
download | ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.gz ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.zst ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.zip |
chore: convert files to TS (#2066)
Diffstat (limited to 'src/i18n')
-rw-r--r-- | src/i18n/apply-branding.ts | 16 |
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 | */ |
4 | import fs from 'fs-extra'; | 4 | import { readdirSync, readJson, writeJson } from 'fs-extra'; |
5 | import path from 'path'; | 5 | import { join } from 'path'; |
6 | 6 | ||
7 | console.log('Applying Ferdi branding to translations...'); | 7 | console.log('Applying Ferdi branding to translations...'); |
8 | 8 | ||
@@ -31,13 +31,13 @@ const replace = { | |||
31 | '!!!': '', | 31 | '!!!': '', |
32 | }; | 32 | }; |
33 | 33 | ||
34 | const locales = path.join(__dirname, 'locales'); | 34 | const locales = join(__dirname, 'locales'); |
35 | const files = fs.readdirSync(locales); | 35 | const files = readdirSync(locales); |
36 | 36 | ||
37 | const replaceFind = Object.keys(replace); | 37 | const replaceFind = Object.keys(replace); |
38 | const replaceReplaceWith = Object.values(replace); | 38 | const replaceReplaceWith = Object.values(replace); |
39 | 39 | ||
40 | const replaceStr = (str, find, replaceWith) => { | 40 | const 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 | }); |