-
Notifications
You must be signed in to change notification settings - Fork 35
Make --files-from work like in gettext
#75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,14 @@ function xgettext(input, options, cb) { | |
| if (options['files-from']) { | ||
| input = fs.readFileSync(options['files-from'], options['from-code']) | ||
| .split('\n') | ||
| .map(function (line) { | ||
| return line.split('').reduceRight(function(acc, c) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (' \t\r'.indexOf(c) === -1 || acc.length > 0) { | ||
| return c + acc; | ||
| } | ||
| return acc; | ||
| }, ''); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, having to loop through all characters just to remove the last ones feels quite heavy. |
||
| }) | ||
| .filter(function (line) { | ||
| return line.trim().length > 0; | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| fixtures/template.hbs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| fixtures/template.hbs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The combination of this line and the lines you added feels a bit like a mix of 2 solutions.
I'd choose either of these:
.split(/\r\n|\r|\n/)to split immediately and forget about \t and space.To get the core functionality you were after, I'm perfectly fine with the second option. Of course getting close to GNU gettext is the goal, but this would already be a step in that direction.