m2mtech / weblate-translation-provider

Weblate translation provider for Symfony Translation.
MIT License
15 stars 9 forks source link

Upload error is too verbose #9

Open jawira opened 3 weeks ago

jawira commented 3 weeks ago

Hello, sometimes "push" command doesn't work properly, in such situation "weblate-translation-provider" will throw an exception and then dump the whole xlf file in the terminal.

Sometimes translation files are really big (for example I have 900KB xlf files), the problem is that terminal is flooded with XML when an exception occur. This is also a problem for error trackers (like Sentry or Glitchtip) because they receive 900K exceptions, which IMHO is useless.

Here an example:

Error thrown while running command "translation:push --ansi --no-interaction weblate". Message: "Unable to upload weblate translation <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
  <file source-language="fr" target-language="nl" datatype="plaintext" original="file.ext">
    <header>
   (+ 900K of data here)

Can we replace the xml data with, for example, the filename ? This will allow to have shorter exception messages.

I can create a PR if you want.

Thank you :)

m2mtech commented 3 weeks ago

Thank you for bringing this up. I agree that dumping the entire XLF file in the terminal during exceptions is not ideal. It’s unlikely that the full content of the XLF file would ever be necessary outside of debugging or developing the service itself.

A more efficient approach would be to add a configuration setting to enable verbose output only when needed or tie it to Symfony's command verbosity levels.

Feel free to create a PR with this adjustment - it's a sensible improvement!

Thanks for your contribution!