aboutsummaryrefslogtreecommitdiffstats
path: root/src/i18n/apply-branding.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/i18n/apply-branding.js')
-rw-r--r--src/i18n/apply-branding.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/i18n/apply-branding.js b/src/i18n/apply-branding.js
index 7aeabc4af..8ec573919 100644
--- a/src/i18n/apply-branding.js
+++ b/src/i18n/apply-branding.js
@@ -7,7 +7,7 @@ const path = require('path');
7console.log('Applying Ferdi branding to translations...'); 7console.log('Applying Ferdi branding to translations...');
8 8
9// Keys to ignore when applying branding 9// Keys to ignore when applying branding
10const ignore = [ 10const ignore = new Set([
11 'login.customServerSuggestion', 11 'login.customServerSuggestion',
12 'login.customServerQuestion', 12 'login.customServerQuestion',
13 'settings.app.todoServerInfo', 13 'settings.app.todoServerInfo',
@@ -18,10 +18,10 @@ const ignore = [
18 'settings.team.copy', 18 'settings.team.copy',
19 'settings.team.manageAction', 19 'settings.team.manageAction',
20 'settings.app.serverMoneyInfo', 20 'settings.app.serverMoneyInfo',
21]; 21]);
22 22
23// Files to ignore when applying branding 23// Files to ignore when applying branding
24const ignoreFiles = ['.DS_Store', '.', '..']; 24const ignoreFiles = new Set(['.DS_Store', '.', '..']);
25 25
26// What to replace 26// What to replace
27const replace = { 27const replace = {
@@ -38,14 +38,15 @@ const replaceFind = Object.keys(replace);
38const replaceReplaceWith = Object.values(replace); 38const replaceReplaceWith = Object.values(replace);
39 39
40const replaceStr = (str, find, replaceWith) => { 40const replaceStr = (str, find, replaceWith) => {
41 for (let i = 0; i < find.length; i += 1) { 41 for (const [i, element] of find.entries()) {
42 str = str.replace(new RegExp(find[i], 'gi'), replaceWith[i]); 42 str = str.replace(new RegExp(element, 'gi'), replaceWith[i]);
43 } 43 }
44 return str; 44 return str;
45}; 45};
46 46
47// eslint-disable-next-line unicorn/no-array-for-each
47files.forEach(async file => { 48files.forEach(async file => {
48 if (ignoreFiles.includes(file)) return; 49 if (ignoreFiles.has(file)) return;
49 50
50 // Read locale data 51 // Read locale data
51 const filePath = path.join(locales, file); 52 const filePath = path.join(locales, file);
@@ -53,7 +54,7 @@ files.forEach(async file => {
53 54
54 // Replace branding 55 // Replace branding
55 for (const key in locale) { 56 for (const key in locale) {
56 if (!ignore.includes(key)) { 57 if (!ignore.has(key)) {
57 locale[key] = replaceStr(locale[key], replaceFind, replaceReplaceWith); 58 locale[key] = replaceStr(locale[key], replaceFind, replaceReplaceWith);
58 } 59 }
59 } 60 }