plural i18n.tr doesn't work as per documentation

Bug #1204141 reported by Michał Sawicz
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Ubuntu UI Toolkit
New
Medium
Tim Peeters

Bug Description

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

The doc 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

Michał Sawicz (saviq)
description: updated
Changed in ubuntu-ui-toolkit:
assignee: nobody → Tim Peeters (tpeeters)
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.