瀏覽代碼

add untranslated.xml containing strings that didn't pass the translation process yet. updateTranslations.sh will add those entries of untranslated.xml that are not yet included in the localized source files

cyberta 6 年之前
父節點
當前提交
648d4ece8a
共有 4 個文件被更改,包括 142 次插入26 次删除
  1. 46 25
      convertTranslations.js
  2. 43 0
      en.lproj/Localizable.strings
  3. 47 0
      untranslated.xml
  4. 6 1
      updateTranslations.sh

+ 46 - 25
convertTranslations.js

@@ -134,7 +134,6 @@ function parseJS(data) {
 
 
 function toIOS(lines) {
 function toIOS(lines) {
   let out = '';
   let out = '';
-  
   for (let line of lines) {
   for (let line of lines) {
                 if (typeof line === 'string') {
                 if (typeof line === 'string') {
             if (line === '') {
             if (line === '') {
@@ -246,36 +245,58 @@ function toJS(lines) {
   });
   });
 }
 }
 
 
-
-function convertAndroidToIOS(stringsXML, appleStrings) {
-  // Read the entire file asynchronously, with a callback to replace the r's and l's
-  // with w's then write the result to the new file.
-  fs.readFile(stringsXML, 'utf-8', function (err, text) {
-      if (err) {
-        console.error("Couuld not read file " + stringsXML);
-        throw err;
+function merge(base, addendum){
+  var out = [].concat(base).filter(value => {
+    return value != null;
+  });
+  for(let i in addendum){
+    add = true;
+    for (let j in base) {
+      if (base[j][0] != undefined &&
+        addendum[i][0] != undefined &&
+        base[j][0] === addendum[i][0]) {
+        add = false;
+        break;
       }
       }
-  
-      let parsed = parseAndroid(text);
-      let iosFormatted = toIOS(parsed);
-      //var fuddified = text.replace(/[rl]/g, 'w').replace(/[RL]/g, 'W')
-      fs.writeFile(output, iosFormatted, function (err) {
-          if (err) {
-            console.error("Error converting " + stringsXML + " to " + appleStrings);
-            throw err;
-          }
-      });
+    }
+    if (add) {
+      out.push(addendum[i]);
+    } else {
+      console.warn(addendum[i] + " is already included. Consider removing it from the additional string source!")
+    }
+  }
+  return out;
+}
+
+function parseAndroidAndAppend(parsedItems, stringsXML) {
+  var text = fs.readFileSync(stringsXML, 'utf-8').toString();
+  let result = parseAndroid(text)
+  return merge(parsedItems, result);
+}
+
+function convertAndroidToIOS(stringsXMLArray, appleStrings) {
+  var parsedItems = [];
+  for (entry of stringsXMLArray) {
+    parsedItems = parseAndroidAndAppend(parsedItems, entry)
+    console.log("parsed " + parsedItems.length + " elements of " + entry)
+  }
+
+  let iosFormatted = toIOS(parsedItems);
+  fs.writeFile(output, iosFormatted, function (err) {
+    if (err) {
+      console.error("Error converting " + stringsXMLArray + " to " + appleStrings);
+      throw err;
+    }
   });
   });
-  
 }
 }
 
 
-if (process.argv.length !== 4) {
-    console.error('Exactly two arguments required. \nExample:\n ' + 
-    " node convertTranslations.js stringsInputfile.xml stringsOutputfile.strings");
+if (process.argv.length < 4) {
+    console.error('Too less arguments provided. \nExample:\n ' + 
+    "node convertTranslations.js stringsInputfile1.xml stringsInputfile2.xml stringsInputfileN.xml stringsOutputfile.strings");
     process.exit(1);
     process.exit(1);
 }
 }
 
 
 
 
-var input = process.argv[2];
-var output = process.argv[3];
+var input = process.argv.slice(2, process.argv.length - 1)
+var output = process.argv[process.argv.length - 1];
 convertAndroidToIOS(input, output)
 convertAndroidToIOS(input, output)

+ 43 - 0
en.lproj/Localizable.strings

@@ -626,3 +626,46 @@
 "language_uk" = "Ukrainian";
 "language_uk" = "Ukrainian";
 "language_zh_CN" = "Chinese";
 "language_zh_CN" = "Chinese";
 
 
+
+"email" = "Email";
+"contact_nickname" = "new contacts nickname";
+"imap_password" = "your IMAP password";
+"success" = "Success";
+"videos" = "Videos";
+"configuring_account" = "Configuring Account";
+"hide" = "Hide";
+"login_error_title" = "Unable to login!";
+"login_successful_title" = "Login successful!";
+"login_successful_message" = "\"You are ready to use Delta Chat.\"";
+"start_chat" = "Start Chat";
+"dismiss" = "Dismiss";
+"photo" = "Photo";
+"search_contact" = "Search Contact";
+"import_contacts" = "Import Device Contacts";
+"import_contacts_message" = "To chat with contacts from your device open the settings menu and enable the Contacts option";
+"synchronizing_account" = "Synchronizing Account";
+"invalid_qr_code" = "Invalid group QR Code";
+"open_settings" = "Open Settings";
+"my_profile" = "My Profile";
+"no_account_setup" = "No Account set up";
+"create_backup" = "Create backup";
+"delete_account" = "Delete Account";
+"delete_account_message" = "Are you sure you wante to delete your account data?";
+"display_name" = "Display Name";
+"status" = "Status";
+"configure_my_account" = "Configure my Account";
+"save_mime_headers" = "Save Mime Headers";
+"flags" = "Flags";
+"user_details" = "User Details";
+"danger" = "Danger";
+"creating_backup" = "Creating Backup";
+"group_info" = "Group Info";
+"next" = "Next";
+"reset" = "Reset";
+"your_status" = "Your Status";
+"edit_contact" = "Edit contact";
+"custom_port" = "Custom Port";
+"automatic" = "Automatic";
+"complete" = "Complete";
+"mailbox" = "Mailbox";
+"info" = "Info";

+ 47 - 0
untranslated.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <!-- iOS specific untranslated strings -->
+    <string name="email">Email</string>
+    <string name="contact_nickname">new contacts nickname</string>
+    <string name="imap_password">your IMAP password</string>
+    <string name="success">Success</string>
+    <string name="videos">Videos</string>
+    <string name="configuring_account">Configuring Account</string>
+    <string name="hide">Hide</string>
+    <string name="login_error_title">Unable to login!</string>
+    <string name="login_successful_title">Login successful!</string>
+    <string name="login_successful_message">"You are ready to use Delta Chat."</string>
+    <string name="start_chat">Start Chat</string>
+    <string name="dismiss">Dismiss</string>
+    <string name="photo">Photo</string>
+    <string name="search_contact">Search Contact</string>
+    <string name="import_contacts">Import Device Contacts</string>
+    <string name="import_contacts_message">To chat with contacts from your device open the settings menu and enable the Contacts option</string>
+    <string name="synchronizing_account">Synchronizing Account</string>
+    <string name="invalid_qr_code">Invalid group QR Code</string>
+    <string name="open_settings">Open Settings</string>
+    <string name="my_profile">My Profile</string>
+    <string name="no_account_setup">No Account set up</string>
+    <string name="create_backup">Create backup</string>
+    <string name="delete_account">Delete Account</string>
+    <string name="delete_account_message">Are you sure you wante to delete your account data?</string>
+    <string name="display_name">Display Name</string>
+    <string name="status">Status</string>
+    <string name="configure_my_account">Configure my Account</string>
+    <string name="save_mime_headers">Save Mime Headers</string>
+    <string name="flags">Flags</string>
+    <string name="user_details">User Details</string>
+    <string name="danger">Danger</string>
+    <string name="creating_backup">Creating Backup</string>
+    <string name="group_info">Group Info</string>
+    <string name="next">Next</string>
+    <string name="reset">Reset</string>
+    <string name="your_status">Your Status</string>
+    <string name="edit_contact">Edit contact</string>
+    <string name="custom_port">Custom Port</string>
+    <string name="automatic">Automatic</string>
+    <string name="complete">Complete</string>
+    <string name="mailbox">Mailbox</string>
+    <string name="info">Info</string>
+</resources>

+ 6 - 1
updateTranslations.sh

@@ -36,7 +36,12 @@ cd ..
 for (( i=0; i<${#IOS_TRANSLATIONS[@]}; i++ )) {
 for (( i=0; i<${#IOS_TRANSLATIONS[@]}; i++ )) {
     LANG_DIR=`echo ${IOS_TRANSLATIONS[i]} | cut -d "." -f2 | cut -c 2-`
     LANG_DIR=`echo ${IOS_TRANSLATIONS[i]} | cut -d "." -f2 | cut -c 2-`
     echo "convertTranslations: $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml -> ${IOS_TRANSLATIONS[i]}"
     echo "convertTranslations: $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml -> ${IOS_TRANSLATIONS[i]}"
-    node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml ${IOS_TRANSLATIONS[i]}
+    if [[ $LANG_DIR == "en" && -f untranslated.xml ]] 
+    then
+        node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml untranslated.xml ${IOS_TRANSLATIONS[i]}
+    else 
+        node convertTranslations.js $TMP_ANDROID_TRANSLATIONS/$LANG_DIR/strings.xml ${IOS_TRANSLATIONS[i]}
+    fi
 }
 }
 
 
 rm -rf $TMP_ANDROID_TRANSLATIONS
 rm -rf $TMP_ANDROID_TRANSLATIONS