tolgee / tolgee-cli

The Tolgee CLI
MIT License
15 stars 11 forks source link

gettext PO - Error 500 when pushing a new translation with a source reference #97

Open aplumez opened 1 month ago

aplumez commented 1 month ago

Description

When using tolgee push for .PO files containing source references, the import fails with a 500 error.

If we import the same file (with the source references) from the website, it works perfectly.

How to reproduce

  1. Pull the translations with the CLI - example of resulting file:
    
    msgid ""
    msgstr ""
    "Language: fr\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"
    "X-Generator: Tolgee\n"

msgid "Login" msgstr "Connexion"

msgid "Password" msgstr "Mot de passe"

2. Add a new translation with a source reference (note that source references on existing keys do not produce the error):
```po
msgid ""
msgstr ""
"Language: fr\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"
"X-Generator: Tolgee\n"

#: dir/file.py:42
msgid "A new translation"
msgstr "En français!"

msgid "Login"
msgstr "Connexion"

msgid "Password"
msgstr "Mot de passe"
  1. Push the translations with the CLI, and you'll get the following result:
    🐭✅     Reading files...
    🐭✅     Uploading files...
    🐭✅     Importing...
    🔴 API reported a server error. Please try again later [status: 500, code: unexpected_error_occurred]
  2. Remove the source reference and you'll be able to push
stepan662 commented 1 month ago

Seems like the .po parser is somehow broken, however it's a mystery why it works when imported through platform