overtake / TelegramSwift

Source code of Telegram for macos on Swift 5.0
https://macos.telegram.org
GNU General Public License v2.0
4.91k stars 818 forks source link

[Bug] "%1$@ invited %2$@" is translated incorrectly into other languages. #1078

Open LeonGeorgi opened 4 months ago

LeonGeorgi commented 4 months ago

If some people are invited to the group, the info text is wrong in some languages.

Problem

The German one says C hat eingeladenA where it should say C hat A eingeladen: telegram-cloud-photo-size-2-5359674201482581276-x

The Dutch one says C nodigde uitA where it should probably (I don't speak Dutch) say C nodigde A uit telegram-cloud-photo-size-2-5359674201482581278-x

In English it works, but most likely just because the invited peers are naturally the last part of the sentence in English: telegram-cloud-photo-size-2-5359674201482581275-x

Problem origin

I already checked the translations, but they are not the problem. In German, for example, it is defined correctly as %1$@ hat %2$@ eingeladen. I am almost 100% sure the problem is coming from this code: https://github.com/overtake/TelegramSwift/blob/a09ea6e609c648264239a5cdbb72947f7aefb531/Telegram-Mac/ChatServiceItem.swift#L202-L213

More specifically, you can see that the string is generated here:

attributedString.append(string: strings().chatServiceGroupAddedMembers1(authorName, ""), …)

And after that the names are appended:

attributedString.append(string: peer.displayTitle, …)
…
attributedString.append(string: ", ", …)

This behaviour is clearly wrong. I hope this can be fixed soon, because this problem has been bothering me for years. Only now I had the courage to finally find out more about the problem.