[QT/TS] File exporter has issues with plurals!

Just found out today. When Crowdin exports translation to “English, Great Britain” mutation to TS (Qt) file, header in XML looks like this:

<TS version="2.1" language="en-GB" sourcelanguage="en">

but it should look like this:

<TS version="2.1" language="en_GB" sourcelanguage="en">

Notice the “_” (correct) vs “-” (wrong) in language code! Wrong language code (for example “en-GB”) results in pluralisation rules NOT being loaded by Qt runtime and breaks plural strings in applications.

2 Likes

Hi @martinrotter,

You are welcome to change the code inside the file with the Resource File Processing App for Crowdin - Simplify Translation Workflow app. It can help you change the code in the way you need it on the export :slight_smile:

Hello, you do not get it.

ALL generated TS FILES are wrong and broken!

Could you please tell us what exactly is broken in the TS files? Did you try to use app to change a language code?

Yes, in the end I use your proposed solution to fix the language codes.

Result can be seen here. New Crowdin updates by martinrotter · Pull Request #1188 · martinrotter/rssguard · GitHub

Problem is that QT is internally using extended language codes with underscore “_” and not with dash “-”.

So if TS file with language=“en-US” gets compiled into QM file and then loaded by QTranslator in QT/c++ source code, QT library does not recognize what actual language the translation is.

Translation gets loaded and user sees translated strings but QT does not load proper pluralisation rules because of unrecognized language. This causes all plural strings to be incorrectly displayed in all QT-based applications for all languages which have extended codes (“en-US”, “en-GB”, “pt-BR”, etc.).

In most file formats, Crowdin uses standard language codes by default. You’re welcome to verify these codes on our reference page here: Crowdin Language Codes

For specific or custom requirements, we offer various additional apps that can modify language codes as needed.

Crowdin really uses wrong lang code format for .ts files. In old Qts (Qt4 and Qt5) it works but Qt6 requires uses underscore in lange code. See console command for .ts file downloaded from Crowding.

[taurus@lix torrent-file-editor]$ lupdate-qt6 . -ts translations/torrentfileeditor_pt.ts 
Scanning directory '.'...
File /home/taurus/develop/torrent-file-editor/translations/torrentfileeditor_pt.ts won't be updated: it contains translation but the target language is not recognized
[taurus@lix torrent-file-editor]$ head -n 3 translations/torrentfileeditor_pt.ts
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pt-BR" sourcelanguage="en">
[taurus@lix torrent-file-editor]$ lupdate-qt5 . -ts translations/torrentfileeditor_pt.ts 
Scanning directory '.'...
Updating 'translations/torrentfileeditor_pt.ts'...
    Found 130 source text(s) (0 new and 130 already existing)
[taurus@lix torrent-file-editor]$ sed -i 's/language="pt-BR"/language="pt_BR"/' translations/torrentfileeditor_pt.ts
[taurus@lix torrent-file-editor]$ lupdate-qt6 . -ts translations/torrentfileeditor_pt.ts 
Scanning directory '.'...
Updating 'translations/torrentfileeditor_pt.ts'...
    Found 130 source text(s) (0 new and 130 already existing)

Hi @drizt and @martinrotter

Sorry for all the confusion here and thank you for bringing it to our attention!

I have discussed it with our team and we have created an improvement task on the matter to make export compatible with all qt SDK versions.

Once it is done we will let you know. As for now please kindly use the workaround with Regex Content Processor app

(Internal task number for the support team only CN-52391)