php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 132 forks source link

Handling of defective .po files #282

Closed jonasraoni closed 1 year ago

jonasraoni commented 2 years ago

If I try to load a .po file with the following content:

msgid "message.id"
msgstr "this line is ok"
this line is missing the initial quote"

It works, but the defective line is ignored. It would be great if the package could log a warning or fail with an exception (this could be probably configurable with a "strict mode", disabled by default to keep the compatibility).

I'll take a look in the code, perhaps I can contribute with another PR if you think the idea is ok.

oscarotero commented 2 years ago

Yeah, it makes sense to me. PR is appreciated, thanks!

jonasraoni commented 2 years ago

Great, I'll take a look at the code and .po format, which is short and try to come up with something generic. My objective is to also be able to use the package to validate/identify broken files, as I've flagged more types of invalid content in my review.

jonasraoni commented 2 years ago

FYI, I've checked the .po format and I think it's too superficial, it's missing a lot of small details 🤔 I'll address the things that I saw and come up with a proposal.

jonasraoni commented 2 years ago