Repository: i18next/i18next-parser (js)

Issue:
How to tell parser to ignore default values in t function?
- Is this a bug or a feature request?

Help question

- What version are you running (`0.x` or `1.x`)? 

1.x

- Which runner (cli, gulp...)?

CLI

## What I'm trying to do?

How to tell i18nparser to **not** use the t function default value?

```
t("key", "test")
```

```
t("key", {defaultValue: "test"})
```

results in

en.json
```
{
   key: "test"
}
```

But i want

en.json
```
{
   key: ""
}
```

**Background**: Default values are very useful for developers when working on MVP. Parsing the keys and pushing them to a third party translation service **including** default values, **won't** mark translation keys as "untranslated"!

---

This is my parser config

```
  createOldCatalogs: true,
  defaultNamespace: "common",
  namespaceSeparator: ":",
  defaultValue: "",
  indentation: 2,
  lexers: {
    js: ["JsxLexer"],
    default: ["JsxLexer"],
  },
  lineEnding: "auto",
  locales: locales,
  output: "./public/locales/$LOCALE/$NAMESPACE.json",
  input: ["./**/*.js"],
  reactNamespace: true,
  useKeysAsDefaultValue: false,
  verbose: true,
  keepRemoved: false,
```

Pull request description:
Added support for skipping default values
closes #216

- Added a new option "skipDefaultValues"
- False by default
- Useful option if communicating from react to third party translation services

Patch:
diff --git a/README.md b/README.md
index 037932c..35ac92b 100644
--- a/README.md
+++ b/README.md
@@ -182,8 +182,11 @@ module.exports = {
   // Whether to use the keys as the default value; ex. "Hello": "Hello", "World": "World"
   // The option `defaultValue` will not work if this is set to true
 
-  verbose: false
+  verbose: false,
   // Display info about the parsing including some stats
+
+  skipDefaultValues: false,
+  // Whether to ignore default values.
 }
 ```
 
diff --git a/src/helpers.js b/src/helpers.js
index 6aea43a..09672dd 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -19,6 +19,11 @@ function dotPathToHash(entry, target = {}, options = {}) {
 
   const separator = options.separator || '.'
   let newValue = entry.defaultValue || options.value || ''
+
+  if (options.skipDefaultValues) {
+    newValue = ""
+  }
+
   if (options.useKeysAsDefaultValue) {
     newValue = entry.key.substring(entry.key.indexOf(separator) + separator.length, entry.key.length)
   }
diff --git a/src/transform.js b/src/transform.js
index f2c7f43..6c437db 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -40,6 +40,7 @@ export default class i18nTransform extends Transform {
       sort: false,
       useKeysAsDefaultValue: false,
       verbose: false,
+      skipDefaultValues: false
     }
 
     this.options = { ...this.defaults, ...options }
@@ -140,7 +141,8 @@ export default class i18nTransform extends Transform {
             suffix,
             separator: this.options.keySeparator,
             value: this.options.defaultValue,
-            useKeysAsDefaultValue: this.options.useKeysAsDefaultValue
+            useKeysAsDefaultValue: this.options.useKeysAsDefaultValue,
+            skipDefaultValues: this.options.skipDefaultValues,
           }
         )
 


Test patch:
diff --git a/test/parser.test.js b/test/parser.test.js
index b12c883..3d073d3 100644
--- a/test/parser.test.js
+++ b/test/parser.test.js
@@ -1018,6 +1018,36 @@ describe('parser', () => {
       i18nextParser.end(fakeFile)
     })
 
+    it("supports skipDefaultValues option", (done) => {
+      let result
+      const i18nextParser = new i18nTransform({
+        skipDefaultValues: true
+      })
+
+      const fakeFile = new Vinyl({
+        contents: Buffer.from(
+          "t('headline1', 'There will be a headline here.') \n" +
+          "t('headline2', {defaultValue: 'Another Headline here'}})",
+        ),
+        path: 'file.js'
+      })
+
+      i18nextParser.on('data', file => {
+        result = JSON.parse(file.contents)
+      })
+
+      i18nextParser.on('end', () => {
+        assert.deepEqual(result, {
+          'headline1': '',
+          'headline2': '',
+        })
+
+        done()
+      })
+
+      i18nextParser.end(fakeFile)
+    });
+
     describe('lexers', () => {
       it('support custom lexers options', (done) => {
         let result
@@ -1055,7 +1085,7 @@ describe('parser', () => {
             return content.split(';').map(key => ({ key }))
           }
 
-          on() {}
+          on() { }
         }
 
         let result
@@ -1092,7 +1122,7 @@ describe('parser', () => {
             return content.split(this.delimiter).map(key => ({ key }))
           }
 
-          on() {}
+          on() { }
         }
 
         let result