Skip to content

Commit

Permalink
feat: added comments support in the csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
samk-dev committed Apr 5, 2024
1 parent 62fce4f commit 9c625bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ This will generate a CSV file that looks like this:

**Be sure to set the delimiter to comma in your csv editor** `,`

**You can use comments in your csv file** using `#`

✨ Tip: you can use [Edit CSV Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=janisdd.vscode-edit-csv) to manage your csv file inside of `vscode`

<details>
Expand All @@ -82,6 +84,11 @@ This will generate a CSV file that looks like this:
hello,"Hello","Bonjour","Hallo"
goodbye,"Goodbye","Au revoir","Auf Wiedersehen"
thanks,"Thanks","Merci","Danke"
# COMMENTS TEST
comment-test,"Comment test","Test comentario","Test comentari"
### MULTILINE COMMENT ###
### ANOTHER COMMENT ####
comment-multi,"Comment test","Test comentario","Test comentari"
```

</details>
Expand Down
5 changes: 5 additions & 0 deletions playground/locales/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ login,"Login","Acceder",Accedir
logout,"Logout","Cerrar sesión",Tencar sesió
tomorrow,"Tomorrow","Mañana",Demà
hmr,"hmr","hmr",hmr
# COMMENTS TEST
comment-test,"Comment test","Test comentario","Test comentari"
### MULTILINE COMMENT ###
### ANOTHER COMMENT ####
comment-multi,"Comment test","Test comentario","Test comentari"
2 changes: 1 addition & 1 deletion src/generateLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function generateLocales(

return new Promise((resolve, reject) => {
fs.createReadStream(csvFilePath)
.pipe(csv())
.pipe(csv({ skipComments: true }))
.on('data', (row) => processRow(row))
.on('end', () => {
// Sort the keys alphabetically
Expand Down

0 comments on commit 9c625bb

Please sign in to comment.