[tor-commits] [pluggable-transports/snowflake-webext] branch main updated: Use manually maintained list for availableLangs

gitolite role git at cupani.torproject.org
Fri Nov 11 14:46:41 UTC 2022


This is an automated email from the git hooks/post-receive script.

cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.

The following commit(s) were added to refs/heads/main by this push:
     new 3e35de8  Use manually maintained list for availableLangs
3e35de8 is described below

commit 3e35de884edf47e37d67df72ccba839e96c3ec36
Author: Cecylia Bocovich <cohosh at torproject.org>
AuthorDate: Tue Nov 1 12:22:25 2022 -0400

    Use manually maintained list for availableLangs
    
    Since the translation backend software changed, we no longer have
    the ability to distinguish which locales have completed translations
    from the git repository. For now we can track and update the supported
    languages manually.
---
 README.md |  7 ++++++
 make.js   | 81 ++++++++++++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 94569bd..cc6cecb 100644
--- a/README.md
+++ b/README.md
@@ -124,6 +124,13 @@ git clean -n -d -x
 # check with the following,
 git submodule update --remote
 
+# We manage the translations we include manually. These translations are
+# tracked separately for the website and the badge. Visit weblate to see
+# the percentage completion for each language and update `websiteLangs`
+# and `badgeLangs` in `make.js` accordingly. The links for weblate are:
+# https://hosted.weblate.org/projects/tor/snowflake-badge/
+# https://hosted.weblate.org/projects/tor/snowflake-website/
+
 # But note that it's also run as part of the "pack-webext" script, so return
 # it to previously committed state,
 git submodule update
diff --git a/make.js b/make.js
index 0506158..3ab3ab9 100755
--- a/make.js
+++ b/make.js
@@ -2,7 +2,43 @@
 
 /* global require, process */
 
-var { writeFileSync, readFileSync, readdirSync, statSync } = require('fs');
+const websiteLangs = [
+  'en_US',
+  'sq',
+  'zh_CN',
+  'cs',
+  'ka',
+  'de',
+  'el',
+  'it',
+  'fa',
+  'pl',
+  'ro',
+  'es',
+  'sv_SE',
+  'tr',
+  'uk',
+];
+
+const badgeLangs = [
+  'en_US',
+  'sq',
+  'zh_CN',
+  'cs',
+  'ka',
+  'de',
+  'el',
+  'it',
+  'fa',
+  'pl',
+  'ro',
+  'es',
+  'sv_SE',
+  'tr',
+  'uk',
+];
+
+var { writeFileSync, readFileSync } = require('fs');
 var { execSync, spawn } = require('child_process');
 var cldr = require('cldr');
 var domino = require('domino');
@@ -49,9 +85,17 @@ var concatJS = function(outDir, init, outFile, pre) {
   execSync(`cat ${files.join(' ')} >> ${outPath}`);
 };
 
-var copyTranslations = function(outDir) {
+var copyTranslations = function(outDir, type) {
+  var langs = [];
+  if (type === "badge") {
+    langs = badgeLangs;
+  } else {
+    langs = websiteLangs;
+  }
   execSync('git submodule update --init -- translation');
-  execSync(`cp -rf translation/* ${outDir}/_locales/`);
+  for (const lang of langs) {
+    execSync(`cp -rf translation/${lang} ${outDir}/_locales/`);
+  }
 };
 
 var getDisplayName = function(locale) {
@@ -68,21 +112,16 @@ var getDisplayName = function(locale) {
   return name;
 };
 
-var getDirs = function() {
-  let dirs = readdirSync('translation').filter((f) => {
-    const s = statSync(`translation/${f}`);
-    return s.isDirectory() && !/^(\.|en)/.test(f);
-  });
-  dirs.push('en_US');
-  dirs.sort();
-  return dirs;
-};
-
-var translatedLangs = function() {
+var translatedLangs = function(type) {
+  var langs = [];
+  if (type === "badge") {
+    langs = badgeLangs;
+  } else {
+    langs = websiteLangs;
+  }
   let out = "const availableLangs = new Map([\n";
-  let dirs = getDirs();
-  dirs = dirs.map(d => `['${d}', '${getDisplayName(d)}'],`);
-  out += dirs.join("\n");
+  langs = langs.map(d => `['${d}', '${getDisplayName(d)}'],`);
+  out += langs.join("\n");
   out += "\n]);\n\n";
   return out;
 };
@@ -155,9 +194,9 @@ task('build', 'build the snowflake proxy', function() {
   execSync(`rm -rf ${outDir}`);
   execSync(`cp -r ${STATIC}/ ${outDir}/`);
   addVersion(outDir);
-  copyTranslations(outDir);
-  concatJS(outDir, 'badge', 'embed.js', translatedLangs());
-  writeFileSync(`${outDir}/index.js`, translatedLangs(), 'utf8');
+  copyTranslations(outDir, "badge");
+  concatJS(outDir, 'badge', 'embed.js', translatedLangs("badge"));
+  writeFileSync(`${outDir}/index.js`, translatedLangs("website"), 'utf8');
   execSync(`cat ${STATIC}/index.js >> ${outDir}/index.js`);
   fillIndex(outDir);
   console.log('Snowflake prepared.');
@@ -187,7 +226,7 @@ function buildWebext(browserEngine) {
     );
     execSync(`rm ${manfestBasePath}`);
   }
-  copyTranslations(outDir);
+  copyTranslations(outDir, "website");
   concatJS(outDir, 'webext', 'snowflake.js', '');
   for (const [key, value] of Object.entries(definitions)) {
     const commandStart = `sed -i "s/${key}/${value}/g" ${outDir}`;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list