Comment 0 for bug 1204141

Revision history for this message
MichaƂ Sawicz (saviq) wrote :

http://developer.ubuntu.com/api/ubuntu-12.10/qml/mobile/qml-ubuntu-components0-i18n.html#tr-method-2

states:

> string i18n::tr(string singular, string plural, int n)

> Translate the given input string singular or plural (depending on the number of items n) using gettext. Should be called like this: > tr("%n file", "%n files", count)

But the following snippet:

> import QtQuick 2.0
> import Ubuntu.Components 0.1
>
> Text {
> text: i18n.tr("singular: %n", "plural: %n", 1) + "<br>" + i18n.tr("singular: %n", "plural: %n", 2)
> }

Displays:

> singular: %n
> plural: %n

A simple workaround:

> import QtQuick 2.0
> import Ubuntu.Components 0.1
>
> Text {
> text: i18n.tr("singular: %1", "plural: %1", 1).arg(1) + "<br>" + i18n.tr("singular: %1", "plural: %1", 2).arg(2)
> }

Displays, correctly:

> singular: 1
> plural: 2