[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake-webext/master] Factor out a common getDir function



commit 387ad5d243b5224c6ca0cefc4b6bc479ebdb9b8a
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Thu Jan 14 14:52:00 2021 -0500

    Factor out a common getDir function
---
 make.js | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/make.js b/make.js
index 00c49b2..38408aa 100755
--- a/make.js
+++ b/make.js
@@ -67,14 +67,19 @@ var getDisplayName = function(locale) {
   return name;
 };
 
-var availableLangs = function() {
-  let out = "const availableLangs = new Set([\n";
+var getDirs = function() {
   let dirs = readdirSync('translation').filter((f) => {
     const s = statSync(`translation/${f}`);
     return s.isDirectory();
   });
   dirs.push('en_US');
   dirs.sort();
+  return dirs;
+};
+
+var availableLangs = function() {
+  let out = "const availableLangs = new Set([\n";
+  let dirs = getDirs();
   dirs = dirs.map(d => `  '${d}',`);
   out += dirs.join("\n");
   out += "\n]);\n\n";
@@ -83,12 +88,7 @@ var availableLangs = function() {
 
 var translatedLangs = function() {
   let out = "const availableLangs = {\n";
-  let dirs = readdirSync('translation').filter((f) => {
-    const s = statSync(`translation/${f}`);
-    return s.isDirectory();
-  });
-  dirs.push('en_US');
-  dirs.sort();
+  let dirs = getDirs();
   dirs = dirs.map(d => `'${d}': {"name": '${getDisplayName(d)}'},`);
   out += dirs.join("\n");
   out += "\n};\n\n";



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits