mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdecore: remove old QTranslator virtual method overload
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
67c09731b4
commit
a9ef1523ff
6 changed files with 16 additions and 49 deletions
|
@ -43,23 +43,12 @@ public:
|
|||
setObjectName(QLatin1String("kdetranslator"));
|
||||
}
|
||||
|
||||
// provides virtuals for old and new method
|
||||
virtual QString translate(const char *context,
|
||||
const char *sourceText) const
|
||||
QString translate(const char *context, const char *sourceText) const final
|
||||
{
|
||||
return KGlobal::locale()->translateQt(context, sourceText, 0);
|
||||
return KGlobal::locale()->translateQt(context, sourceText);
|
||||
}
|
||||
|
||||
virtual QString translate(const char *context,
|
||||
const char *sourceText,
|
||||
const char *message,
|
||||
const char *disambiguation = 0) const
|
||||
{
|
||||
Q_UNUSED(disambiguation);
|
||||
return KGlobal::locale()->translateQt(context, sourceText, message);
|
||||
}
|
||||
|
||||
virtual bool isEmpty() const
|
||||
bool isEmpty() const final
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -175,9 +175,9 @@ void KLocale::translateRaw(const char *ctxt, const char *singular, const char *p
|
|||
d->translateRawFrom(0, ctxt, singular, plural, n, lang, trans);
|
||||
}
|
||||
|
||||
QString KLocale::translateQt(const char *context, const char *sourceText, const char *comment) const
|
||||
QString KLocale::translateQt(const char *context, const char *sourceText) const
|
||||
{
|
||||
return d->translateQt(context, sourceText, comment);
|
||||
return d->translateQt(context, sourceText);
|
||||
}
|
||||
|
||||
QList<KLocale::DigitSet> KLocale::allDigitSetsList() const
|
||||
|
|
|
@ -1788,7 +1788,7 @@ public:
|
|||
* The parameters are similar to i18n(), but the result
|
||||
* value has other semantics (it can be QString())
|
||||
*/
|
||||
QString translateQt(const char *context, const char *sourceText, const char *comment) const;
|
||||
QString translateQt(const char *context, const char *sourceText) const;
|
||||
|
||||
/**
|
||||
* Provides list of all known language codes.
|
||||
|
|
|
@ -966,29 +966,13 @@ void KLocalePrivate::translateRawFrom(const char *catname, const char *msgctxt,
|
|||
}
|
||||
}
|
||||
|
||||
QString KLocalePrivate::translateQt(const char *context, const char *sourceText, const char *comment) const
|
||||
QString KLocalePrivate::translateQt(const char *context, const char *sourceText) const
|
||||
{
|
||||
// Qt's context is normally the name of the class of the method which makes
|
||||
// Katie's context is normally the name of the class of the method which makes
|
||||
// the tr(sourceText) call. However, it can also be manually supplied via
|
||||
// translate(context, sourceText) call.
|
||||
//
|
||||
// Qt's sourceText is the actual message displayed to the user.
|
||||
//
|
||||
// Qt's comment is an optional argument of tr() and translate(), like
|
||||
// tr(sourceText, comment) and translate(context, sourceText, comment).
|
||||
//
|
||||
// We handle this in the following way:
|
||||
//
|
||||
// If the comment is given, then it is considered gettext's msgctxt, so a
|
||||
// context call is made.
|
||||
//
|
||||
// If the comment is not given, but context is given, then we treat it as
|
||||
// msgctxt only if it was manually supplied (the one in translate()) -- but
|
||||
// we don't know this, so we first try a context call, and if translation
|
||||
// is not found, we fallback to ordinary call.
|
||||
//
|
||||
// If neither comment nor context are given, it's just an ordinary call
|
||||
// on sourceText.
|
||||
// Katie's sourceText is the actual message displayed to the user.
|
||||
|
||||
if (!sourceText || !sourceText[0]) {
|
||||
kDebug(173) << "KLocale: trying to look up \"\" in catalog. "
|
||||
|
@ -1006,17 +990,11 @@ QString KLocalePrivate::translateQt(const char *context, const char *sourceText,
|
|||
// NOTE: Condition (language != defaultLanguage()) means that translation
|
||||
// was found, otherwise we got the original string back as translation.
|
||||
|
||||
if (comment && comment[0]) {
|
||||
// Comment given, go for context call.
|
||||
translateRawFrom(0, comment, sourceText, 0, 0, &language, &translation);
|
||||
} else {
|
||||
// Comment not given, go for try-fallback with context.
|
||||
if (context && context[0]) {
|
||||
translateRawFrom(0, context, sourceText, 0, 0, &language, &translation);
|
||||
}
|
||||
if (language.isEmpty() || language == defaultLanguage()) {
|
||||
translateRawFrom(0, 0, sourceText, 0, 0, &language, &translation);
|
||||
}
|
||||
if (context && context[0]) {
|
||||
translateRawFrom(0, context, sourceText, 0, 0, &language, &translation);
|
||||
}
|
||||
if (language.isEmpty() || language == defaultLanguage()) {
|
||||
translateRawFrom(0, 0, sourceText, 0, 0, &language, &translation);
|
||||
}
|
||||
|
||||
if (language != defaultLanguage()) {
|
||||
|
|
|
@ -318,7 +318,7 @@ public:
|
|||
* @internal Translates a message as a QTranslator is supposed to.
|
||||
* The worker of the same-name KLocale API function.
|
||||
*/
|
||||
QString translateQt(const char *context, const char *sourceText, const char *comment) const;
|
||||
QString translateQt(const char *context, const char *sourceText) const;
|
||||
|
||||
/**
|
||||
* @internal Checks whether or not the active catalog is found for the given language.
|
||||
|
|
|
@ -223,7 +223,7 @@ void KLocalizedStringTest::translateToFrench()
|
|||
|
||||
void KLocalizedStringTest::translateQt()
|
||||
{
|
||||
QString result = KGlobal::locale()->translateQt("QPrintPreviewDialog", "Landscape", 0);
|
||||
QString result = KGlobal::locale()->translateQt("QPrintPreviewDialog", "Landscape");
|
||||
// When we use the default language, translateQt returns an empty string.
|
||||
QString expected = m_hasFrench ? QString("Paysage") : QString();
|
||||
QCOMPARE(result, expected);
|
||||
|
|
Loading…
Add table
Reference in a new issue