From 6be8f6de85e1838bd097b42da4acd2337ce6e0f4 Mon Sep 17 00:00:00 2001 From: Caio Fukelmann Landau Date: Wed, 8 Apr 2015 15:31:25 -0300 Subject: [PATCH 1/2] Make discarding empty strings optional. Defaults to enabled in order to keep old functionality the same --- lib/transifex-api.js | 2 +- tasks/transifex.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/transifex-api.js b/lib/transifex-api.js index e3d432a..bc94609 100644 --- a/lib/transifex-api.js +++ b/lib/transifex-api.js @@ -140,7 +140,7 @@ Api.prototype.writeLanguageFiles = function(strings, callback) { if( self.options.mode === "file" ){ transformed = s.strings; } else { - transformed = self.options.templateFn(s.strings.filter(function(s) { return s.translation !== ""; })); + transformed = self.options.templateFn(s.strings.filter(function(s) { return !self.options.filterEmpty || s.translation !== ""; })); } grunt.file.write(filepath, transformed); diff --git a/tasks/transifex.js b/tasks/transifex.js index bd3d1fc..823f340 100644 --- a/tasks/transifex.js +++ b/tasks/transifex.js @@ -17,7 +17,8 @@ module.exports = function(grunt) { reviewed : this.flags.reviewed, mode: "json", filename : "_resource_/_lang_.json", - templateFn: function(strings) { return JSON.stringify(_.object(_.pluck(strings, "key"), _.pluck(strings, "translation"))); } + templateFn: function(strings) { return JSON.stringify(_.object(_.pluck(strings, "key"), _.pluck(strings, "translation"))); }, + filterEmpty:true }); /** Attempt to create target directory From 8da383ad0763ae2f29f6a1a03ac31d8784448da4 Mon Sep 17 00:00:00 2001 From: Caio Fukelmann Landau Date: Wed, 8 Apr 2015 15:47:02 -0300 Subject: [PATCH 2/2] Updating readme with new option --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30ef01e..070d8b0 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Provides a Grunt task that downloads translation strings from Transifex into you resources: ["localizable_enstrings"], languages: ["en_US", "fr"], filename : "_resource_-_lang_.json", + filterEmpty: true, // defaults to true (remove empty strings). Set to false to keep them. templateFn: function(strings) { return ...; } // customize the output file format (see below) } }, @@ -37,7 +38,7 @@ This configuration enables running the `transifex` Grunt task on the command lin 'en_US' and 'fr' grunt transifex:ios-ready:reviewed --> Same as above, but downloads reviewed strings only - + grunt transifex --> Downloads reviewed & non-reviewed strings for all configured Transifex projects grunt transifex::reviewed @@ -56,7 +57,7 @@ Translated strings will saved into plain JSON if you use the default output conf ## Transifex credentials When the plugin runs for the first time, it will prompt the user for a Transifex username and password. -It will store this information in a `.transifexrc` file created in the current directory. +It will store this information in a `.transifexrc` file created in the current directory. On subsequent executions, the user won't be prompted again. Transifex credentials will be read from `.transifexrc`