linguist: Skip CRLF line-ending translation for binary formats


Commit da9087019 added QIODevice::Text to Translator::save on
Windows so that .ts files keep CRLF line endings. Translator::save
is format-agnostic though: it opens the file before dispatching to
the format-specific serializer, and QIODevice::Text translates \n to
\r\n on the underlying QFile, which corrupts binary output such as
.qm files. When lconvert rewrites an existing .qm that happens to
contain a \r\n byte pair in its first 4096 bytes (very likely for
any reasonably-sized binary), usesCRLF() returned true and the write
doubled every \n byte, producing a file with the correct qm magic
but garbled content. QTranslator then silently rejected it at load
time.

Resolve the FileFormat handler up front in save() and reuse it for
both the binary-format gate and the saver dispatch. Text formats
(.ts, .po, .xlf, .qph, ...) retain their existing CRLF preservation
behaviour; any format registered as TranslationBinary is always
written in pure binary mode. Pulling the handler ahead also drops a
duplicated extension-matching loop and a separate "auto" fallback
that previously had to stay in sync with guessFormat().

Change-Id: I17b544971d68ae3f13dfd8e7f110c30ef1eec686
Reviewed-by: Masoud Jami <masoud.jami@qt.io>
commit78d045ae20400b6d534985b3e9d7129f7fd5828d
parent07312347e1ad7c57f44654c7639fab99d36b42e7
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>
commit timeMon, 27 Apr 2026 16:56:56 +0000