aboutsummaryrefslogtreecommitdiffstats
path: root/src/i18n/apply-branding.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-09-19 14:48:35 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-09-19 14:48:35 +0200
commit03ef2426a75d0a8468f7dcd9367d8b7b19ae0b30 (patch)
tree433e6f96edf4ac2fb348bcbd8c84ec2b96b4338c /src/i18n/apply-branding.js
parentApply branding to locales (diff)
downloadferdium-app-03ef2426a75d0a8468f7dcd9367d8b7b19ae0b30.tar.gz
ferdium-app-03ef2426a75d0a8468f7dcd9367d8b7b19ae0b30.tar.zst
ferdium-app-03ef2426a75d0a8468f7dcd9367d8b7b19ae0b30.zip
Fix lint
Diffstat (limited to 'src/i18n/apply-branding.js')
-rw-r--r--src/i18n/apply-branding.js64
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
10const ignore = [ 10const 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
15const ignoreFiles = [ 15const 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
23const replace = { 23const replace = {
24 'franz': 'Ferdi', 24 franz: 'Ferdi',
25 'meetfranz.com': 'getferdi.com' 25 'meetfranz.com': 'getferdi.com',
26} 26};
27 27
28 28
29const locales = path.join(__dirname, 'locales'); 29const locales = path.join(__dirname, 'locales');
30const files = fs.readdirSync(locales) 30const files = fs.readdirSync(locales);
31 31
32const replaceFind = Object.keys(replace); 32const replaceFind = Object.keys(replace);
33const replaceReplaceWith = Object.values(replace); 33const replaceReplaceWith = Object.values(replace);
34 34
35const replaceStr = (str, find, replace) => { 35const 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
42files.forEach(async file => {
43 if (ignoreFiles.includes(file)) return;
44 41
45 // Read locale data 42files.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});