i18next / i18next-gettext-converter

converts gettext .mo or .po to 18next json format and vice versa
MIT License
196 stars 56 forks source link

No error thrown when error in .po file #147

Closed jashment closed 2 years ago

jashment commented 2 years ago

🐛 Bug Report

When there is an issue in a translated .po file, the error isn't thrown and no information is logged about the error. For example:

msgid "This is a string" msgstr "This is a "string"

Where the error is an extra set of quotes right before the msgstr "string". Given the above .po file, no error will be raised, nothing will be written, and "file written" will be incorrectly logged.

To Reproduce

  1. Create a simple .po file using the following:

    simple .po file

    
    msgid ""
    msgstr ""
    "Project-Id-Version: i18next-conv\n"
    "mime-version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Plural-Forms: nplurals=2; plural=(n > 1)\n"
    "POT-Creation-Date: 2022-02-04T22:13:20.856Z\n"
    "PO-Revision-Date: 2022-02-04T22:13:20.856Z\n"
    "Language: en\n"

msgid "This is a string" msgstr "This is a "string"

2. Use i18next-conv with the following command:
```js
i18next-conv -l en -s en.po -t out.json
  1. The conversion will say "file written" in green. If you try to find out.json, it will not exist.

Expected behavior

An error is raised indicating what went wrong and that no file is written.

output(in red) file not written Syntax Error: Error occured in line 13 before at "string"

Your Environment