libraries, creating uncertainty/bugs in using QString easily, and (to a lesser
extent) performance issues.
-* QTextCodec::codecForTr() and QTextCodec::setCodecForTr() have been removed,
- QCoreApplication::Encoding value CodecForTr is now obsolete, use
- DefaultCodec instead. For reasoning, see the codecForCStrings() removal above.
+* QTextCodec::codecForTr() and QTextCodec::setCodecForTr() have been removed.
+ QObject::trUtf8 and QCoreApplication::Encoding enum are now obsolete. Qt assumes
+ that the source code is encoded in UTF-8.
* QFile::setEncodingFunction and QFile::setDecodingFunction are obsolete and do
nothing in Qt 5. The QFile::encodeName and QFile::decodeName functions are now
}
/*! \enum QCoreApplication::Encoding
+ \obsolete
- This enum type defines the 8-bit encoding of character string
- arguments to translate():
+ This enum type used to define the 8-bit encoding of character string
+ arguments to translate(). This enum is now obsolete and UTF-8 will be
+ used in all cases.
\value UnicodeUTF8 UTF-8.
- \value Latin1 Latin-1.
- \value DefaultCodec Latin-1.
+ \value Latin1 UTF-8.
+ \value DefaultCodec UTF-8.
- \sa QObject::tr(), QObject::trUtf8(), QString::fromUtf8()
+ \sa QObject::tr(), QString::fromUtf8()
*/
void QCoreApplicationPrivate::ref()
/*!
\reentrant
- \since 4.5
Returns the translation text for \a sourceText, by querying the
installed translation files. The translation files are searched
from the most recently installed file back to the first
installed file.
- QObject::tr() and QObject::trUtf8() provide this functionality
- more conveniently.
+ QObject::tr() provides this functionality more conveniently.
\a context is typically a class name (e.g., "MyDialog") and \a
sourceText is either English text or a short identifying text.
See the \l QTranslator and \l QObject::tr() documentation for
more information about contexts, disambiguations and comments.
- \a encoding indicates the 8-bit encoding of character strings.
-
\a n is used in conjunction with \c %n to support plural forms.
See QObject::tr() for details.
If none of the translation files contain a translation for \a
sourceText in \a context, this function returns a QString
- equivalent of \a sourceText. The encoding of \a sourceText is
- specified by \e encoding; it defaults to DefaultCodec.
+ equivalent of \a sourceText.
This function is not virtual. You can use alternative translation
techniques by subclassing \l QTranslator.
\sa QObject::tr(), installTranslator()
*/
-
-
QString QCoreApplication::translate(const char *context, const char *sourceText,
- const char *disambiguation, Encoding encoding, int n)
+ const char *disambiguation, int n)
{
QString result;
}
}
- if (result.isNull()) {
-#ifdef QT_NO_TEXTCODEC
- Q_UNUSED(encoding)
-#else
- if (encoding == UnicodeUTF8)
- result = QString::fromUtf8(sourceText);
- else
-#endif
- result = QString::fromLatin1(sourceText);
- }
+ if (result.isNull())
+ result = QString::fromUtf8(sourceText);
replacePercentN(&result, n);
return result;
// Declared in qglobal.h
QString qtTrId(const char *id, int n)
{
- return QCoreApplication::translate(0, id, 0, QCoreApplication::UnicodeUTF8, n);
+ return QCoreApplication::translate(0, id, 0, n);
}
bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator)
static bool installTranslator(QTranslator * messageFile);
static bool removeTranslator(QTranslator * messageFile);
#endif
- enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = Latin1
-#if QT_DEPRECATED_SINCE(5, 0)
- , CodecForTr = Latin1
-#endif
- };
+
static QString translate(const char * context,
const char * key,
const char * disambiguation = 0,
- Encoding encoding = DefaultCodec,
int n = -1);
+#if QT_DEPRECATED_SINCE(5, 0)
+ enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 };
+ QT_DEPRECATED static inline QString translate(const char * context, const char * key,
+ const char * disambiguation, Encoding, int n = -1)
+ { return translate(context, key, disambiguation, n); }
+#endif
static void flush();
{ if (event) event->spont = true; return self ? self->notifyInternal(receiver, event) : false; }
#ifdef QT_NO_TRANSLATION
-// Simple versions
-inline QString QCoreApplication::translate(const char *, const char *sourceText,
- const char *, Encoding encoding, int)
+inline QString QCoreApplication::translate(const char *, const char *sourceText, const char *, int)
{
-#ifndef QT_NO_TEXTCODEC
- if (encoding == UnicodeUTF8)
- return QString::fromUtf8(sourceText);
-#else
Q_UNUSED(encoding)
-#endif
- return QString::fromLatin1(sourceText);
+ return QString::fromUtf8(sourceText);
}
+#if QT_DEPRECATED_SINCE(5, 0)
+QT_DEPRECATED inline QString QCoreApplication::translate(const char *, const char *sourceText, const char *, Encoding encoding, int)
+{
+ Q_UNUSED(encoding)
+ return QString::fromUtf8(sourceText);
+}
+#endif
#endif
#define Q_DECLARE_TR_FUNCTIONS(context) \
public: \
static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) \
- { return QCoreApplication::translate(#context, sourceText, disambiguation, \
- QCoreApplication::DefaultCodec, n); } \
- static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \
- { return QCoreApplication::translate(#context, sourceText, disambiguation, \
- QCoreApplication::UnicodeUTF8, n); } \
+ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
+ QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \
+ { return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
private:
typedef void (*QtCleanUpFunction)();
*/
QString QMetaObject::tr(const char *s, const char *c, int n) const
{
- return QCoreApplication::translate(rawStringData(this, 0), s, c, QCoreApplication::DefaultCodec, n);
-}
-
-/*!
- \internal
-*/
-QString QMetaObject::trUtf8(const char *s, const char *c, int n) const
-{
- return QCoreApplication::translate(rawStringData(this, 0), s, c, QCoreApplication::UnicodeUTF8, n);
+ return QCoreApplication::translate(rawStringData(this, 0), s, c, n);
}
#endif // QT_NO_TRANSLATION
#endif
#ifdef QT_NO_TRANSLATION
static QString tr(const char *sourceText, const char * = 0, int = -1)
- { return QString::fromLatin1(sourceText); }
-#ifndef QT_NO_TEXTCODEC
- static QString trUtf8(const char *sourceText, const char * = 0, int = -1)
+ { return QString::fromUtf8(sourceText); }
+#if QT_DEPRECATED_SINCE(5, 0)
+ QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = 0, int = -1)
{ return QString::fromUtf8(sourceText); }
#endif
#endif //QT_NO_TRANSLATION
#endif // QT_NO_META_MACROS
#ifndef QT_NO_TRANSLATION
-# ifndef QT_NO_TEXTCODEC
// full set of tr functions
# define QT_TR_FUNCTIONS \
static inline QString tr(const char *s, const char *c = 0, int n = -1) \
{ return staticMetaObject.tr(s, c, n); } \
- static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) \
- { return staticMetaObject.trUtf8(s, c, n); }
-# else
-// no QTextCodec, no utf8
-# define QT_TR_FUNCTIONS \
- static inline QString tr(const char *s, const char *c = 0, int n = -1) \
+ QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) \
{ return staticMetaObject.tr(s, c, n); }
-# endif
#else
// inherit the ones from QObject
# define QT_TR_FUNCTIONS
#ifndef QT_NO_TRANSLATION
QString tr(const char *s, const char *c, int n = -1) const;
- QString trUtf8(const char *s, const char *c, int n = -1) const;
#endif // QT_NO_TRANSLATION
int methodOffset() const;