kdecore: remove redundant KLocale::translateRaw() methods

context can be null now

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-27 21:21:57 +03:00
parent 20e92c8398
commit 12f3ffd120
4 changed files with 5 additions and 56 deletions

View file

@ -526,11 +526,6 @@ void KLocale::setActiveCatalog(const QString &catalog)
KLocalizedString::notifyCatalogsUpdated(languageList());
}
void KLocale::translateRaw(const char *msg, QString *lang, QString *trans) const
{
translateRaw(nullptr, msg, lang, trans);
}
void KLocale::translateRaw(const char *ctxt, const char *msg, QString *lang, QString *trans) const
{
foreach (const KCatalog &catalog, d->catalogs) {
@ -549,12 +544,6 @@ void KLocale::translateRaw(const char *ctxt, const char *msg, QString *lang, QSt
*trans = QString::fromUtf8(msg);
}
void KLocale::translateRaw(const char *singular, const char *plural, unsigned long n, QString *lang,
QString *trans) const
{
translateRaw(nullptr, singular, plural, n, lang, trans);
}
void KLocale::translateRaw(const char *ctxt, const char *singular, const char *plural,
unsigned long n, QString *lang, QString *trans) const
{

View file

@ -412,24 +412,6 @@ public:
*/
void setActiveCatalog(const QString &catalog);
/**
* @since 4.5
*
* Raw translation from all loaded catalogs.
*
* Never use this directly to get message translations. See the i18n and ki18n family of calls
* related to KLocalizedString.
*
* @param msg the message. Must not be null or empty. Must be UTF-8 encoded.
* @param lang language in which the translation was found. If no translation was found,
* KLocale::defaultLanguage() is reported. If null, the language is not reported.
* @param trans raw translation, or original if not found. If no translation was found,
* original message is reported. If null, the translation is not reported.
*
* @see KLocalizedString
*/
void translateRaw(const char *msg, QString *lang, QString *trans) const;
/**
* @since 4.5
*
@ -439,7 +421,7 @@ public:
* Never use this directly to get message translations. See @p i18n and @p ki18n calls related
* to KLocalizedString.
*
* @param ctxt the context. Must not be null. Must be UTF-8 encoded.
* @param ctxt the context. May be null. Must be UTF-8 encoded.
* @param msg the message. Must not be null or empty. Must be UTF-8 encoded.
* @param lang language in which the translation was found. If no translation was found,
* KLocale::defaultLanguage() is reported. If null, the language is not reported.
@ -450,28 +432,6 @@ public:
*/
void translateRaw(const char *ctxt, const char *msg, QString *lang, QString *trans) const;
/**
* @since 4.5
*
* Raw translation from all loaded catalogs, with given singular/plural form. Singular form is
* used as the lookup key in the catalog.
*
* Never use this directly to get message translations. See @p i18n and @p ki18n calls related
* to KLocalizedString.
*
* @param singular the singular form. Must not be null or empty. Must be UTF-8 encoded.
* @param plural the plural form. Must not be null. Must be UTF-8 encoded.
* @param n number on which the forms are decided.
* @param lang language in which the translation was found. If no translation was found,
* KLocale::defaultLanguage() is reported. If null, the language is not reported.
* @param trans raw translation, or original if not found. If no translation was found,
* original message is reported (either plural or singular, as determined by
* @p n). If null, the translation is not reported.
*
* @see KLocalizedString
*/
void translateRaw(const char *singular, const char *plural, unsigned long n,
QString *lang, QString *trans) const;
/**
* @since 4.5
*
@ -481,7 +441,7 @@ public:
* Never use this directly to get message translations. See @p i18n and @p ki18n calls related
* to KLocalizedString.
*
* @param ctxt the context. Must not be null. Must be UTF-8 encoded.
* @param ctxt the context. May be null. Must be UTF-8 encoded.
* @param singular the singular form. Must not be null or empty. Must be UTF-8 encoded.
* @param plural the plural form. Must not be null. Must be UTF-8 encoded.
* @param n number on which the forms are decided.

View file

@ -167,11 +167,11 @@ QString KLocalizedStringPrivate::toString (const KLocale *locale) const
if (!ctxt.isEmpty() && !plural.isEmpty()) {
locale->translateRaw(ctxt, msg, plural, number, &lang, &rawtrans);
} else if (!plural.isEmpty()) {
locale->translateRaw(msg, plural, number, &lang, &rawtrans);
locale->translateRaw(nullptr, msg, plural, number, &lang, &rawtrans);
} else if (!ctxt.isEmpty()) {
locale->translateRaw(ctxt, msg, &lang, &rawtrans);
} else {
locale->translateRaw(msg, &lang, &rawtrans);
locale->translateRaw(nullptr, msg, &lang, &rawtrans);
}
} else {
lang = KLocale::defaultLanguage();

View file

@ -229,7 +229,7 @@ void KLocalizedStringTest::translateQt()
// So let's use translateRaw instead for the threaded test
QString lang;
KGlobal::locale()->translateRaw("Landscape", &lang, &result);
KGlobal::locale()->translateRaw(nullptr, "Landscape", &lang, &result);
QCOMPARE(lang, m_hasFrench ? QString("fr") : QString("en_US")); // it finds it in kdeqt.po
QCOMPARE(result, m_hasFrench ? QString("Paysage") : QString("Landscape"));
}