merge translate() overloads

Change-Id: I58f0d2c2ec6da751860a90096c49c662658643c1
Reviewed-on: http://codereview.qt-project.org/5164
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Oswald Buddenhagen 2011-09-19 20:18:08 +02:00 committed by Qt by Nokia
parent 4f1e2aa27a
commit 91d2ee5e09
2 changed files with 5 additions and 25 deletions

View File

@ -906,42 +906,25 @@ void QTranslatorPrivate::clear()
new QEvent(QEvent::LanguageChange));
}
/*!
Returns the translation for the key (\a context, \a sourceText,
\a disambiguation). If none is found, also tries (\a context, \a
sourceText, ""). If that still fails, returns an empty string.
If you need to programatically insert translations in to a
QTranslator, this function can be reimplemented.
\sa load()
*/
QString QTranslator::translate(const char *context, const char *sourceText, const char *disambiguation) const
{
Q_D(const QTranslator);
return d->do_translate(context, sourceText, disambiguation, -1);
}
/*!
\overload translate()
Returns the translation for the key (\a context, \a sourceText,
\a disambiguation). If none is found, also tries (\a context, \a
sourceText, ""). If that still fails, returns an empty string.
sourceText, ""). If that still fails, returns a null string.
If \a n is not -1, it is used to choose an appropriate form for
the translation (e.g. "%n file found" vs. "%n files found").
If you need to programatically insert translations into a
QTranslator, this function can be reimplemented.
\sa load()
*/
QString QTranslator::translate(const char *context, const char *sourceText, const char *disambiguation,
int n) const
{
Q_D(const QTranslator);
// this step is necessary because the 3-parameter translate() overload is virtual
if (n == -1)
return translate(context, sourceText, disambiguation);
return d->do_translate(context, sourceText, disambiguation, n);
}

View File

@ -63,11 +63,8 @@ public:
explicit QTranslator(QObject *parent = 0);
~QTranslator();
// ### Qt 5: Merge (with "int n = -1")
virtual QString translate(const char *context, const char *sourceText,
const char *disambiguation = 0) const;
QString translate(const char *context, const char *sourceText, const char *disambiguation,
int n) const;
const char *disambiguation = 0, int n = -1) const;
virtual bool isEmpty() const;