diff --git a/i18n/crowdin_update.js b/i18n/crowdin_update.js index a83269da2..0a39b6db7 100644 --- a/i18n/crowdin_update.js +++ b/i18n/crowdin_update.js @@ -10,12 +10,32 @@ var bhttp = require('bhttp'); var crowdin_identifier = 'copay' var local_file_name1 = path.join(__dirname, 'po/template.pot') + +// Similar to Github, normalize all line breaks to CRLF so that different people +// using different OSes to update does not constantly swith format back and forth. +var local_file1_text = fs.readFileSync(local_file_name1, 'utf8'); +local_file1_text = local_file1_text.replace('\r\n', '\n'); +local_file1_text = local_file1_text.replace('\n', '\r\n'); +fs.writeFileSync(local_file_name1, local_file1_text); + var local_file1 = fs.createReadStream(local_file_name1) var local_file_name2 = path.join(__dirname, 'docs/appstore_en.txt') + +var local_file2_text = fs.readFileSync(local_file_name2, 'utf8'); +local_file2_text = local_file2_text.replace('\r\n', '\n'); +local_file2_text = local_file2_text.replace('\n', '\r\n'); +fs.writeFileSync(local_file_name2, local_file2_text); + var local_file2 = fs.createReadStream(local_file_name2) var local_file_name3 = path.join(__dirname, 'docs/updateinfo_en.txt') + +var local_file3_text = fs.readFileSync(local_file_name3, 'utf8'); +local_file3_text = local_file3_text.replace('\r\n', '\n'); +local_file3_text = local_file3_text.replace('\n', '\r\n'); +fs.writeFileSync(local_file_name3, local_file3_text); + var local_file3 = fs.createReadStream(local_file_name3) // obtain the crowdin api key @@ -31,11 +51,14 @@ if (crowdin_api_key != '') { }; bhttp.post('https://api.crowdin.com/api/project/' + crowdin_identifier + '/update-file?key=' + crowdin_api_key, payload, {}, function(err, response) { - console.log('Response from update file call:', response.body.toString()); + console.log('\nResponse from update file call:\n', response.body.toString()); // This call will tell the server to generate a new zip file for you based on most recent translations. https.get('https://api.crowdin.com/api/project/' + crowdin_identifier + '/export?key=' + crowdin_api_key, function(res) { console.log('Export Got response: ' + res.statusCode); + res.on('data', function(chunk) { + console.log(chunk.toString('utf8')); + }); }).on('error', function(e) { console.log('Export Got error: ' + e.message); });