[Development] QTranslator - line feed character

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Tue Oct 11 18:08:56 CEST 2022


On 11/10/2022 11:19, EXT Panajotis Daras via Development wrote:
> 
> I wanted to ask whether the current behavior in the translation module 
> is correct.
> In short, the question is about the line feed character in the 
> translation file:
> 
>     // hellotr_la.ts file
>     <?xml version="1.0"  encoding="utf-8"?>
>     <!DOCTYPE TS>
>     <TS version="2.1"  language="lv_LV">
>     <context>
>          <name>QPushButton</name>
>          <message>
>              <source>Hello</source>
>              <translation>Hello*\n*world!</translation>
>          </message>
>     </context>
>     </TS>
> 
> The customer expects that the translated text will be formatted with 
> respect to the line feed character. 
That is incorrect.

You have "\n" in your .ts file, and that has no special meaning in XML. 
It literally means backslash followed by 'n'. Therefore, when you load 
the translation, you get precisely that sequence (backslash+n).

If you have a real newline in the TS file (or an equivalent sequence, 
e.g. 
) then you'll get a newline when loading the translation.

This works out of the box when using Linguist, just insert a newline in 
the translation field by pressing enter.

My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20221011/c65b4f4c/attachment.bin>


More information about the Development mailing list