diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/i18n/apply-branding.js | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/i18n/apply-branding.js b/src/i18n/apply-branding.js index 98fdce963..39497967e 100644 --- a/src/i18n/apply-branding.js +++ b/src/i18n/apply-branding.js | |||
@@ -8,53 +8,53 @@ console.log('Applying Ferdi branding to translations...'); | |||
8 | 8 | ||
9 | // Keys to ignore when applying branding | 9 | // Keys to ignore when applying branding |
10 | const ignore = [ | 10 | const ignore = [ |
11 | 'login.customServerSuggestion' | 11 | 'login.customServerSuggestion', |
12 | ] | 12 | ]; |
13 | 13 | ||
14 | // Files to ignore when applying branding | 14 | // Files to ignore when applying branding |
15 | const ignoreFiles = [ | 15 | const ignoreFiles = [ |
16 | 'defaultMessages.json', | 16 | 'defaultMessages.json', |
17 | '.DS_Store', | 17 | '.DS_Store', |
18 | '.', | 18 | '.', |
19 | '..' | 19 | '..', |
20 | ] | 20 | ]; |
21 | 21 | ||
22 | // What to replace | 22 | // What to replace |
23 | const replace = { | 23 | const replace = { |
24 | 'franz': 'Ferdi', | 24 | franz: 'Ferdi', |
25 | 'meetfranz.com': 'getferdi.com' | 25 | 'meetfranz.com': 'getferdi.com', |
26 | } | 26 | }; |
27 | 27 | ||
28 | 28 | ||
29 | const locales = path.join(__dirname, 'locales'); | 29 | const locales = path.join(__dirname, 'locales'); |
30 | const files = fs.readdirSync(locales) | 30 | const files = fs.readdirSync(locales); |
31 | 31 | ||
32 | const replaceFind = Object.keys(replace); | 32 | const replaceFind = Object.keys(replace); |
33 | const replaceReplaceWith = Object.values(replace); | 33 | const replaceReplaceWith = Object.values(replace); |
34 | 34 | ||
35 | const replaceStr = (str, find, replace) => { | 35 | const replaceStr = (str, find, replaceWith) => { |
36 | for (var i = 0; i < find.length; i++) { | 36 | for (let i = 0; i < find.length; i += 1) { |
37 | str = str.replace(new RegExp(find[i], 'gi'), replace[i]); | 37 | str = str.replace(new RegExp(find[i], 'gi'), replaceWith[i]); |
38 | } | 38 | } |
39 | return str; | 39 | return str; |
40 | } | 40 | }; |
41 | |||
42 | files.forEach(async file => { | ||
43 | if (ignoreFiles.includes(file)) return; | ||
44 | 41 | ||
45 | // Read locale data | 42 | files.forEach(async (file) => { |
46 | const filePath = path.join(locales, file); | 43 | if (ignoreFiles.includes(file)) return; |
47 | let locale = await fs.readJson(filePath); | ||
48 | 44 | ||
49 | // Replace branding | 45 | // Read locale data |
50 | for (const key in locale) { | 46 | const filePath = path.join(locales, file); |
51 | if (ignore.includes(key)) return; | 47 | const locale = await fs.readJson(filePath); |
52 | 48 | ||
53 | locale[key] = replaceStr(locale[key], replaceFind, replaceReplaceWith); | 49 | // Replace branding |
50 | for (const key in locale) { | ||
51 | if (!ignore.includes(key)) { | ||
52 | locale[key] = replaceStr(locale[key], replaceFind, replaceReplaceWith); | ||
54 | } | 53 | } |
54 | } | ||
55 | 55 | ||
56 | await fs.writeJson(filePath, locale, { | 56 | await fs.writeJson(filePath, locale, { |
57 | spaces: 2, | 57 | spaces: 2, |
58 | EOL: '\n', | 58 | EOL: '\n', |
59 | }); | 59 | }); |
60 | }) \ No newline at end of file | 60 | }); |