i18n

i18n is a context property that provides internationalization support. More...

Properties

Methods

Detailed Description

i18n cannot be instantiated, and is already available as a context property. It is based on gettext, and thus the standard gettext tools can be used for translating a project. Example:

import QtQuick 2.0
import Ubunut.Components 0.1

Item {
     width: units.gu(40)
     height: units.gu(50)

     Button {
         anchors.centerIn: parent
         text: i18n.tr("Press me")
     }
}

Property Documentation

domain : string

The gettext domain to be used for the translation. The default domain is the applicationName specified in the application's MainView, or the empty string "" if no applicationName was given or no MainView is used. Use dtr() functions instead of tr() to use a different domain for a single translation that ignores i18n.domain.


language : string

The language that is used for the translation. The default value is the user's locale dending on $LC_ALL, $LC_MESSAGES and $LANG at the time of running the application. See the gettext manual for details.


Method Documentation

string i18n::dtr(string domain, string singular, string plural, int n)

Translate the given text using gettext. Should be called like this: tr(domain, "%n file", "%n files", count) Uses domain for the domain instead of i18n.domain, and singular or plural as input for the translation depending on the number of items n.


string i18n::dtr(string domain, string text)

Translate text using gettext. Uses the specified domain domain instead of i18n.domain.


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)


string i18n::tr(string text)

Translate text using gettext and return the translation.