-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
#282 Add strict po loader #283
#282 Add strict po loader #283
Conversation
I've tested some weird combinations, but forgot to move them to the unit test 🤦 |
Hi. |
Hi! There's no "strict" syntax, I just mimicked the behavior of the GNU tools, which I think is a good guide (given the documentation is missing details) :) For example, the msgctxt"context"msgid"message"msgstr"translation" But it fails if you try to parse things in the wrong order, with an invalid So in theory this could replace the current So I'll wait for your feedback. In order to decrease the pain, I could just add a flag, to swallow the exceptions by default, and continue to the next translation... But the input vs output of a defective file won't be the same as the current class. |
…mplete plurals, missing key headers, duplicated/malformed headers)
078246a
to
7981363
Compare
… file, added method getWarnings() and introduced new function (loadStringExtended) to avoid breaking the Gettext\Loader\Loader contract
b3be188
to
1830ea4
Compare
Ok @oscarotero, I'm done with the performance fixes (more than that will require me to uglify the code even more or drop features). I thought about doing a memory optimization (parse the file by chunks), but that will damage the speed (and my use case doesn't need it: locale files with a max of 170KB) 🤔 If you think it's helpful, I could rebase the commits to mark the |
Thanks @jonasraoni
Yeah, it makes sense. But I think it's not so important, so whatever you want :) One think that I would like is update the README.md file to include this new loader and explain the differences between both PO loaders (including also the difference in performance). As this info is more in your head, could you please add this latest change before merging? Thanks so much! |
…orLine (switch if the error message should show the byte/line where the error happened) to the StrictPoLoader
@oscarotero I've updated the README and the CHANGELOG 👌 |
Thank you! 👍 |
Hi @oscarotero!
I did some initial updates to cover my needs.
StrictPoLoader
.msgfmt -c
(e.g. line break/whitespace is optional almost everywhere) 🫠PoLoader
, but it became too polluted with my checks and I decided to write a new parser...