mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 19:02:48 +00:00
kdecore: do not use final for string storage
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d9cc003262
commit
17dc16afe4
1 changed files with 19 additions and 19 deletions
|
@ -79,7 +79,7 @@ class KLocalizedStringPrivate
|
||||||
int resolveInterpolation (const QString &trans, int pos,
|
int resolveInterpolation (const QString &trans, int pos,
|
||||||
const QString &lang,
|
const QString &lang,
|
||||||
const QString &ctry,
|
const QString &ctry,
|
||||||
const QString &final,
|
const QString &finalstr,
|
||||||
QString &result,
|
QString &result,
|
||||||
bool &fallback) const;
|
bool &fallback) const;
|
||||||
QVariant segmentToValue (const QString &arg) const;
|
QVariant segmentToValue (const QString &arg) const;
|
||||||
|
@ -269,11 +269,11 @@ QString KLocalizedStringPrivate::toString (const KLocale *locale,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substitute placeholders in ordinary translation.
|
// Substitute placeholders in ordinary translation.
|
||||||
QString final = substituteSimple(trans);
|
QString finalstr = substituteSimple(trans);
|
||||||
// Post-format ordinary translation.
|
// Post-format ordinary translation.
|
||||||
final = postFormat(final, lang, QString::fromLatin1(ctxt));
|
finalstr = postFormat(finalstr, lang, QString::fromLatin1(ctxt));
|
||||||
|
|
||||||
return final;
|
return finalstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KLocalizedStringPrivate::selectForEnglish () const
|
QString KLocalizedStringPrivate::selectForEnglish () const
|
||||||
|
@ -367,26 +367,26 @@ QString KLocalizedStringPrivate::substituteSimple (const QString &trans,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Assemble the final string from text segments and arguments.
|
// Assemble the final string from text segments and arguments.
|
||||||
QString final;
|
QString finalstr;
|
||||||
for (int i = 0; i < plords.size(); i++)
|
for (int i = 0; i < plords.size(); i++)
|
||||||
{
|
{
|
||||||
final.append(tsegs.at(i));
|
finalstr.append(tsegs.at(i));
|
||||||
if (plords.at(i) >= args.size())
|
if (plords.at(i) >= args.size())
|
||||||
// too little arguments
|
// too little arguments
|
||||||
{
|
{
|
||||||
// put back the placeholder
|
// put back the placeholder
|
||||||
final.append(QLatin1Char('%') + QString::number(plords.at(i) + 1));
|
finalstr.append(QLatin1Char('%') + QString::number(plords.at(i) + 1));
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!partial)
|
if (!partial)
|
||||||
// spoof the message
|
// spoof the message
|
||||||
final.append(QLatin1String("(I18N_ARGUMENT_MISSING)"));
|
finalstr.append(QLatin1String("(I18N_ARGUMENT_MISSING)"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// just fine
|
// just fine
|
||||||
final.append(args.at(plords.at(i)));
|
finalstr.append(args.at(plords.at(i)));
|
||||||
}
|
}
|
||||||
final.append(tsegs.last());
|
finalstr.append(tsegs.last());
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (!partial)
|
if (!partial)
|
||||||
|
@ -408,15 +408,15 @@ QString KLocalizedStringPrivate::substituteSimple (const QString &trans,
|
||||||
|
|
||||||
// Some spoofs.
|
// Some spoofs.
|
||||||
if (gaps)
|
if (gaps)
|
||||||
final.append(QLatin1String("(I18N_GAPS_IN_PLACEHOLDER_SEQUENCE)"));
|
finalstr.append(QLatin1String("(I18N_GAPS_IN_PLACEHOLDER_SEQUENCE)"));
|
||||||
if (ords.size() < args.size())
|
if (ords.size() < args.size())
|
||||||
final.append(QLatin1String("(I18N_EXCESS_ARGUMENTS_SUPPLIED)"));
|
finalstr.append(QLatin1String("(I18N_EXCESS_ARGUMENTS_SUPPLIED)"));
|
||||||
if (!plural.isEmpty() && !numberSet)
|
if (!plural.isEmpty() && !numberSet)
|
||||||
final.append(QLatin1String("(I18N_PLURAL_ARGUMENT_MISSING)"));
|
finalstr.append(QLatin1String("(I18N_PLURAL_ARGUMENT_MISSING)"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return final;
|
return finalstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KLocalizedStringPrivate::postFormat (const QString &text,
|
QString KLocalizedStringPrivate::postFormat (const QString &text,
|
||||||
|
@ -426,21 +426,21 @@ QString KLocalizedStringPrivate::postFormat (const QString &text,
|
||||||
const KLocalizedStringPrivateStatics *s = staticsKLSP;
|
const KLocalizedStringPrivateStatics *s = staticsKLSP;
|
||||||
QMutexLocker lock(kLocaleMutex());
|
QMutexLocker lock(kLocaleMutex());
|
||||||
|
|
||||||
QString final = text;
|
QString finalstr = text;
|
||||||
|
|
||||||
// Transform any semantic markup into visual formatting.
|
// Transform any semantic markup into visual formatting.
|
||||||
if (s->formatters.contains(lang)) {
|
if (s->formatters.contains(lang)) {
|
||||||
final = s->formatters[lang]->format(final, ctxt);
|
finalstr = s->formatters[lang]->format(finalstr, ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return final;
|
return finalstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KLocalizedStringPrivate::resolveInterpolation (const QString &strans,
|
int KLocalizedStringPrivate::resolveInterpolation (const QString &strans,
|
||||||
int pos,
|
int pos,
|
||||||
const QString &lang,
|
const QString &lang,
|
||||||
const QString &ctry,
|
const QString &ctry,
|
||||||
const QString &final,
|
const QString &finalstr,
|
||||||
QString &result,
|
QString &result,
|
||||||
bool &fallback) const
|
bool &fallback) const
|
||||||
{
|
{
|
||||||
|
@ -513,7 +513,7 @@ int KLocalizedStringPrivate::resolveInterpolation (const QString &strans,
|
||||||
else if (strans.mid(tpos, islen) == s->startInterp) { // sub-interpolation
|
else if (strans.mid(tpos, islen) == s->startInterp) { // sub-interpolation
|
||||||
QString resultLocal;
|
QString resultLocal;
|
||||||
bool fallbackLocal;
|
bool fallbackLocal;
|
||||||
tpos = resolveInterpolation(strans, tpos, lang, ctry, final,
|
tpos = resolveInterpolation(strans, tpos, lang, ctry, finalstr,
|
||||||
resultLocal, fallbackLocal);
|
resultLocal, fallbackLocal);
|
||||||
if (tpos < 0) { // unrecoverable problem in sub-interpolation
|
if (tpos < 0) { // unrecoverable problem in sub-interpolation
|
||||||
// Error reported in the subcall.
|
// Error reported in the subcall.
|
||||||
|
|
Loading…
Add table
Reference in a new issue