Changeset 561 for trunk/tools/linguist/shared/translator.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/linguist/shared/translator.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the Qt Linguist of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 #include <QList> 49 49 #include <QLocale> 50 #include <QMultiHash> 50 51 #include <QString> 52 #include <QSet> 51 53 52 54 53 55 QT_BEGIN_NAMESPACE 56 57 #ifdef QT_BOOTSTRAPPED 58 class QObject { 59 public: 60 static QString tr(const char *sourceText, const char * = 0, int n = -1); 61 }; 62 class QCoreApplication : public QObject { 63 public: 64 enum Encoding { CodecForTr }; 65 static QString translate(const char *, const char *sourceText, const char * = 0, 66 Encoding = CodecForTr, int n = -1) 67 { return tr(sourceText, 0, n); } 68 }; 69 #endif 54 70 55 71 class QIODevice; … … 64 80 m_sortContexts(false), 65 81 m_noUiLines(false), 82 m_idBased(false), 66 83 m_saveMode(SaveEverything) 67 84 {} … … 82 99 public: 83 100 QString m_defaultContext; 84 QByteArray m_codecForSource; // CPP specific 101 QByteArray m_codecForSource; // CPP, PO & QM specific 102 QByteArray m_outputCodec; // CPP & PO specific 103 QString m_unTrPrefix; // QM specific 85 104 QString m_sourceFileName; 86 105 QString m_targetFileName; 87 106 QDir m_sourceDir; 88 QDir m_targetDir; // FIXME: TS spefic 107 QDir m_targetDir; // FIXME: TS specific 108 QSet<QString> m_projectRoots; 109 QMultiHash<QString, QString> m_allCSources; 110 QStringList m_includePath; 89 111 QStringList m_dropTags; // tags to be dropped 90 112 QStringList m_errors; … … 93 115 bool m_sortContexts; 94 116 bool m_noUiLines; 117 bool m_idBased; 95 118 TranslatorSaveMode m_saveMode; 96 119 }; … … 105 128 bool release(QFile *iod, ConversionData &cd) const; 106 129 107 bool contains(const QString &context, const QString &sourceText, 108 const QString &comment) const; 109 TranslatorMessage find(const QString &context, 110 const QString &sourceText, const QString &comment) const; 111 130 int find(const TranslatorMessage &msg) const; 112 131 TranslatorMessage find(const QString &context, 113 132 const QString &comment, const TranslatorMessage::References &refs) const; … … 116 135 TranslatorMessage find(const QString &context) const; 117 136 118 void replace(const TranslatorMessage &msg);119 137 void replaceSorted(const TranslatorMessage &msg); 120 138 void extend(const TranslatorMessage &msg); // Only for single-location messages … … 128 146 void stripIdenticalSourceTranslations(); 129 147 void dropTranslations(); 148 void dropUiLines(); 130 149 void makeFileNamesAbsolute(const QDir &originalPath); 131 QSet<TranslatorMessagePtr> resolveDuplicates(); 132 static void reportDuplicates(const QSet<TranslatorMessagePtr> &dupes, 133 const QString &fileName, bool verbose); 150 151 struct Duplicates { QSet<int> byId, byContents; }; 152 Duplicates resolveDuplicates(); 153 void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); 134 154 135 155 void setCodecName(const QByteArray &name); 136 QByteArray codecName() const { return m_codecName; } 156 QByteArray codecName() const; 157 QTextCodec *codec() const { return m_codec; } 137 158 138 159 QString languageCode() const { return m_language; } 139 160 QString sourceLanguageCode() const { return m_sourceLanguage; } 140 161 141 enum LocationsType { NoLocations, RelativeLocations, AbsoluteLocations };162 enum LocationsType { DefaultLocations, NoLocations, RelativeLocations, AbsoluteLocations }; 142 163 void setLocationsType(LocationsType lt) { m_locationsType = lt; } 143 164 LocationsType locationsType() const { return m_locationsType; } … … 151 172 QList<TranslatorMessage> messages() const; 152 173 QList<TranslatorMessage> translatedMessages() const; 153 static QStringList normalizedTranslations(const TranslatorMessage &m, 154 QLocale::Language lang, QLocale::Country country);174 static QStringList normalizedTranslations(const TranslatorMessage &m, int numPlurals); 175 void normalizeTranslations(ConversionData &cd); 155 176 QStringList normalizedTranslations(const TranslatorMessage &m, ConversionData &cd, bool *ok) const; 156 177 … … 179 200 LoadFunction loader; 180 201 SaveFunction saver; 181 enum FileType { SourceCode,TranslationSource, TranslationBinary } fileType;202 enum FileType { TranslationSource, TranslationBinary } fileType; 182 203 int priority; // 0 = highest, -1 = invisible 183 204 }; … … 185 206 static QList<FileFormat> ®isteredFileFormats(); 186 207 187 enum VariantSeparators{188 DefaultVariantSeparator = 0x2762, // some weird character nobody ever heard of :-D189 InternalVariantSeparator = 0x9c // unicode "STRING TERMINATOR"208 enum { 209 TextVariantSeparator = 0x2762, // some weird character nobody ever heard of :-D 210 BinaryVariantSeparator = 0x9c // unicode "STRING TERMINATOR" 190 211 }; 191 212 … … 194 215 195 216 TMM m_messages; 196 Q ByteArray m_codecName;217 QTextCodec *m_codec; 197 218 LocationsType m_locationsType; 198 219
Note:
See TracChangeset
for help on using the changeset viewer.