|
Grantlee 0.1.9
|
Provides internationalization based on QLocale and QTranslator. More...
#include <qtlocalizer.h>

Public Member Functions | |
| QtLocalizer (const QLocale &locale=QLocale::system()) | |
| virtual | ~QtLocalizer () |
| virtual QString | currentLocale () const |
| void | installTranslator (QTranslator *translator, const QString &localeName=QLocale::system().name()) |
| virtual void | loadCatalog (const QString &path, const QString &catalog) |
| virtual QString | localizeContextString (const QString &string, const QString &context, const QVariantList &arguments=QVariantList()) const |
| virtual QString | localizeDate (const QDate &date, QLocale::FormatType formatType=QLocale::ShortFormat) const |
| virtual QString | localizeDateTime (const QDateTime &dateTime, QLocale::FormatType formatType=QLocale::ShortFormat) const |
| virtual QString | localizeMonetaryValue (qreal value, const QString ¤cyCode=QString()) const |
| virtual QString | localizeNumber (int number) const |
| virtual QString | localizeNumber (qreal number) const |
| virtual QString | localizePluralContextString (const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments=QVariantList()) const |
| virtual QString | localizePluralString (const QString &string, const QString &pluralForm, const QVariantList &arguments=QVariantList()) const |
| virtual QString | localizeString (const QString &string, const QVariantList &arguments=QVariantList()) const |
| virtual QString | localizeTime (const QTime &time, QLocale::FormatType formatType=QLocale::ShortFormat) const |
| virtual void | popLocale () |
| virtual void | pushLocale (const QString &localeName) |
| void | setAppTranslatorPath (const QString &path) |
| void | setAppTranslatorPrefix (const QString &prefix) |
| virtual void | unloadCatalog (const QString &catalog) |
This class implements access to the Qt Localization system. Localizaable types such as strings, numbers, dates and times can be processed.
Template t = m_engine->loadTemplate(someTemplate);
Context c = getContext();
// Render with the German locale
c.setLocalizer(m_de_Localizer);
QString deText = t->render(&c);
de_display->setText(deText);
// Render with the French locale
c.setLocalizer(m_fr_Localizer);
QString frText = t->render(&c);
fr_display->setText(frText);
Definition at line 55 of file qtlocalizer.h.
| Grantlee::QtLocalizer::QtLocalizer | ( | const QLocale & | locale = QLocale::system() | ) |
Constructs a new QtLocalizer using the locale
| virtual Grantlee::QtLocalizer::~QtLocalizer | ( | ) | [virtual] |
Destructor
| virtual QString Grantlee::QtLocalizer::currentLocale | ( | ) | const [virtual] |
Returns the current locale as a string.
Implements Grantlee::AbstractLocalizer.
| void Grantlee::QtLocalizer::installTranslator | ( | QTranslator * | translator, |
| const QString & | localeName = QLocale::system().name() |
||
| ) |
Install a translator to use for a particular localeName.
QTranslator *deTranslator = new QTranslator(this); bool loaded = deTranslator->load("myapp_de_DE"); if (!loaded) return; de_localizer->installTranslator(deTranslator, "de_DE");
| virtual void Grantlee::QtLocalizer::loadCatalog | ( | const QString & | path, |
| const QString & | catalog | ||
| ) | [virtual] |
Loads the catalog from path.
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeContextString | ( | const QString & | string, |
| const QString & | context, | ||
| const QVariantList & | arguments = QVariantList() |
||
| ) | const [virtual] |
Localizes string, disambiguated by context with the specified arguments for substitution
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeDate | ( | const QDate & | date, |
| QLocale::FormatType | formatType = QLocale::ShortFormat |
||
| ) | const [virtual] |
Localizes date with the specified formatType
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeDateTime | ( | const QDateTime & | dateTime, |
| QLocale::FormatType | formatType = QLocale::ShortFormat |
||
| ) | const [virtual] |
Localizes dateTime with the specified formatType
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeMonetaryValue | ( | qreal | value, |
| const QString & | currencyCode = QString() |
||
| ) | const [virtual] |
Localizes value as a monetary value in the currency specified by currencyCode.
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeNumber | ( | int | number | ) | const [virtual] |
Localizes number
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeNumber | ( | qreal | number | ) | const [virtual] |
Localizes number
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizePluralContextString | ( | const QString & | string, |
| const QString & | pluralForm, | ||
| const QString & | context, | ||
| const QVariantList & | arguments = QVariantList() |
||
| ) | const [virtual] |
Localizes string or its pluralForm, disambiguated by context with the specified arguments for substitution
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizePluralString | ( | const QString & | string, |
| const QString & | pluralForm, | ||
| const QVariantList & | arguments = QVariantList() |
||
| ) | const [virtual] |
Localizes string or its pluralForm with the specified arguments for substitution
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeString | ( | const QString & | string, |
| const QVariantList & | arguments = QVariantList() |
||
| ) | const [virtual] |
Localizes string with the specified arguments for substitution
Implements Grantlee::AbstractLocalizer.
| virtual QString Grantlee::QtLocalizer::localizeTime | ( | const QTime & | time, |
| QLocale::FormatType | formatType = QLocale::ShortFormat |
||
| ) | const [virtual] |
Localizes time with the specified formatType
Implements Grantlee::AbstractLocalizer.
| virtual void Grantlee::QtLocalizer::popLocale | ( | ) | [virtual] |
Makes this localizer use the previous locale for output.
Implements Grantlee::AbstractLocalizer.
| virtual void Grantlee::QtLocalizer::pushLocale | ( | const QString & | localeName | ) | [virtual] |
Makes this localizer use the locale specified by localeName for output.
Implements Grantlee::AbstractLocalizer.
| void Grantlee::QtLocalizer::setAppTranslatorPath | ( | const QString & | path | ) |
Set the path to look for translations of the application strings.
| void Grantlee::QtLocalizer::setAppTranslatorPrefix | ( | const QString & | prefix | ) |
Set the prefix of translation files. For example, if the German translation file is called myapp_de_DE.qm, the prefix should be set to myapp_.
| virtual void Grantlee::QtLocalizer::unloadCatalog | ( | const QString & | catalog | ) | [virtual] |
Unloads the catalog
Implements Grantlee::AbstractLocalizer.
1.7.4