smhg / gettext-parser

Parse and compile gettext po and mo files, nothing more, nothing less
MIT License
158 stars 44 forks source link

Charset get lost and casing of header keys changes #12

Closed iongion closed 5 years ago

iongion commented 8 years ago

Headers act weird:

        var translation = {
          charset: "UTF-8",
          headers: {
            "Project-Id-Version": "project 1.0.2",
            "Mime-Version": "1.0",
            "Content-Type": "text/plain; charset=UTF-8",
            "Content-Transfer-Encoding": "8bit",
            "Plural-Forms": "nplurals=2; plural=(n!=1);",
            "X-Poedit-SourceCharset": "UTF-8"
          },
          translations: {}
        }

And the generated files outputs:

msgid ""
msgstr ""
"Project-Id-Version: project 1.0.2\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
"X-Poedit-Sourcecharset: UTF-8\n"
"Content-Type: text/plain;\n"

As you can see, Content-Type header lacks the charset and then the X-Poedit-SourceCharset header casing is weird and confuses 3rd party editors, it becomes X-Poedit-Sourcecharset

Can't the headers be sent as they are ? Without any magic title casing ?

smhg commented 7 years ago

Hi! I took over this project and would like to follow up on this.

For future reference these are 2 separate issues:

danielkcz commented 5 years ago

@smhg Looks like you took over and abandoned again? :) What a pity. Just encountered this issue. Are you available at least for merging PR and publishing or did you lost interest completely?

Either way, I don't agree there should be any "uppercasing" happening. It should really be left in the same state as it was read. Besides various editors doing some shenanigans, this is also super annoying for file versioning. One tool changes headers some way, other tool does it differently and if it happens between commits, it's full of unrelated changes.

smhg commented 5 years ago

I do maintain this project. The few open issues are just the ones for which I'd appreciate PR's. ~Sidenote: for some weird reason I don't get e-mailed when there is a new issue or PR unless you ping me with an @username (so please feel free to always do that).~

Concerning the headers: I think we are all on the same page here. Feel free to submit your solution. Since these are 2 separate issues, maybe separate them into 2 PR's?

danielkcz commented 5 years ago

@smhg Sorry, but we ended up using a different parsing module which works much better. I guess this issue will hang here for another period of time :)

smhg commented 5 years ago

Care to share what worked for you so others can benefit from it?

danielkcz commented 5 years ago

https://github.com/rubenv/pofile

smhg commented 5 years ago

I've changed how headers are handled. The ones from this list have a fixed title case format. All others are left unchanged.

smhg commented 5 years ago

Released on npm as 4.0.0-alpha.0. @iongion @FredyC @vallo87 @AlexMost it would be great if one of you could give it a try.

AlexMost commented 5 years ago

I have checked this on my use case and seems like everything is ok! Thanks a lot!