Translation of plural string in English with spaces

Albert Astals Cid aacid at kde.org
Wed Jan 5 22:21:57 GMT 2022


El dimecres, 5 de gener de 2022, a les 21:07:34 (CET), Johnny Jazeix va escriure:
> Hi,
> 
> for GCompris we have one complicated sentence to translate:
> "Place %n boy(s) and %n girl(s) in the center. Then split %n pieces of
> candy equally between them." (context in this image:
> https://gcompris.net/screenshots_qt/middle/share.png)
> 
> There are mixed plurals and to have the plural correctly translated we use:
>         //~ singular Place %n boy
>         //~ plural Place %n boys
>         text = qsTr("Place %n boy(s) ", "First part of Place %n boy(s) and
> %n girl(s) in the center. Then split %n pieces of candy equally between
> them.", boys);
> 
>         //~ singular and %n girl in the center.
>         //~ plural and %n girls in the center.
>         text += qsTr("and %n girl(s) in the center. ", "Second part of
> Place %n boy(s) and %n girl(s) in the center. Then split %n pieces of candy
> equally between them.", girls);
> 
>         //~ singular Then split %n candy equally between them.
>         //~ plural Then split %n candies equally between them.
>         text += qsTr("Then split %n pieces of candy equally between them.",
> "Third part of Place %n boy(s) and %n girl(s) in the center. Then split %n
> pieces of candy equally between them.", candies);
> 
> For American English, it takes the string from the " //~ singular/plural "
> lines.
> The issue we have is that we don't manage to have the extra space in the
> English translation at the end of "boy(s) " (same if we put the space at
> the beginning of the other part to translate (" and %n girl(s))").
> 
> If we add double quotes, they are part of the translation. And if we have
> an extra space at the end, it is removed.
> 
> Is there a way to handle it properly in the code or even reformulate the
> sentence to make it work more easily while keeping the meaning?
> 
> I'm cc-ing multiple list because, in the ideal, we'd like to fix the code
> without impacting the string for the next release but we can have a better
> string for after.

As you've found the current tooling we use to autofill the en.po files from the comments doesn't allow spaces at the end, and that "can't be fixed" since it means a change in lupdate from qt.

The typical way to solve this kind of puzzles is to translate the 3 strings separately and then have a qsTr("%1 %2. %3") [with lots of context] to merge it all together and potentially give the translation teams that need some extra possibility of repositioning things if they need to.

Cheers,
  Albert

> 
> Cheers,
> 
> Johnny
> 






More information about the kde-devel mailing list