VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
metatranslator.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: Qt Software Information (qt-info@nokia.com)
5 **
6 ** This file is part of the Qt Linguist of the Qt Toolkit.
7 **
8 ** Commercial Usage
9 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** accordance with the Qt Commercial License Agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and Nokia.
13 **
14 **
15 ** GNU General Public License Usage
16 ** Alternatively, this file may be used under the terms of the GNU
17 ** General Public License versions 2.0 or 3.0 as published by the Free
18 ** Software Foundation and appearing in the file LICENSE.GPL included in
19 ** the packaging of this file. Please review the following information
20 ** to ensure GNU General Public Licensing requirements will be met:
21 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
22 ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
23 ** exception, Nokia gives you certain additional rights. These rights
24 ** are described in the Nokia Qt GPL Exception version 1.3, included in
25 ** the file GPL_EXCEPTION.txt in this package.
26 **
27 ** Qt for Windows(R) Licensees
28 ** As a special exception, Nokia, as the sole copyright holder for Qt
29 ** Designer, grants users of the Qt/Eclipse Integration plug-in the
30 ** right for the Qt/Eclipse Integration to link to functionality
31 ** provided by Qt Designer and its related libraries.
32 **
33 ** If you are unsure which license is appropriate for your use, please
34 ** contact the sales department at qt-sales@nokia.com.
35 **
36 ****************************************************************************/
37 
38 #ifndef METATRANSLATOR_H
39 #define METATRANSLATOR_H
40 
41 #include "qxml.h"
42 #include "translator.h"
43 #include <QMap>
44 #include <QString>
45 #include <QList>
46 #include <QtCore/QDir>
47 
48 QT_BEGIN_NAMESPACE
49 
50 class QIODevice;
51 class QTextCodec;
52 class QXmlErrorHandler;
53 
55 {
56 public:
58  MetaTranslator( const MetaTranslator& tor );
59 
61 
62  void clear();
63  bool load( const QString& filename );
64  bool save( const QString& filename ) const;
65  bool release( const QString& filename, bool verbose = false,
66  bool ignoreUnfinished = false,
68  bool release( QIODevice *iod, bool verbose = false,
69  bool ignoreUnfinished = false,
71 
72  bool contains(const QByteArray &context, const QByteArray &sourceText,
73  const QByteArray &comment) const;
74 
75  TranslatorMessage find(const QByteArray &context,
76  const QByteArray &sourceText, const QByteArray &comment) const;
77 
78  TranslatorMessage find(const QByteArray &context,
79  const QByteArray &comment, const QString &fileName, int lineNumber) const;
80 
81  void insert( const TranslatorMessage& m );
82 
83  void stripObsoleteMessages();
84  void stripEmptyContexts();
85  void stripNonPluralForms();
87  void makeFileNamesAbsolute();
88 
89  void setXmlErrorHandler(QXmlErrorHandler* handler) { xmlErrorHandler = handler; }
90  void setCodec( const char *name ); // kill me
91  void setCodecForTr( const char *name ) { setCodec(name); }
92  QTextCodec *codecForTr() const { return codec; }
93  QString toUnicode( const char *str, bool utf8 ) const;
94 
95  QString languageCode() const;
96  static void languageAndCountry(const QString &languageCode, QLocale::Language *lang, QLocale::Country *country);
97  void setLanguageCode(const QString &languageCode);
100  static int grammaticalNumerus(QLocale::Language language, QLocale::Country country);
101  static QStringList normalizedTranslations(const TranslatorMessage& m,
102  QLocale::Language lang, QLocale::Country country);
103 
104 private:
105  typedef QMap<TranslatorMessage, int> TMM; // int stores the sequence position.
106  typedef QMap<int, TranslatorMessage> TMMInv; // Used during save operation. Seems to use the map only the get the sequence order right.
107  bool saveTS( const QString& filename ) const;
108  bool saveXLIFF( const QString& filename) const;
109 
111  QByteArray codecName;
112  QTextCodec *codec;
115 
116  // A string beginning with a 2 or 3 letter language code (ISO 639-1
117  // or ISO-639-2), followed by the optional country variant to distinguish
118  // between country-specific variations of the language. The language code
119  // and country code are always separated by '_'
120  // Note that the language part can also be a 3-letter ISO 639-2 code.
121  // Legal examples:
122  // 'pt' portuguese, assumes portuguese from portugal
123  // 'pt_BR' Brazilian portuguese (ISO 639-1 language code)
124  // 'por_BR' Brazilian portuguese (ISO 639-2 language code)
125  QString m_language;
126 };
127 
128 /*
129  This is a quick hack. The proper way to handle this would be
130  to extend MetaTranslator's interface.
131 */
132 #define ContextComment "QT_LINGUIST_INTERNAL_CONTEXT_COMMENT"
133 
134 bool saveXLIFF( const MetaTranslator &mt, const QString& filename);
135 
136 QT_END_NAMESPACE
137 
138 #endif
void stripNonPluralForms()
void stripObsoleteMessages()
bool save(const QString &filename) const
QTextCodec * codec
Definition: metatranslator.h:112
void setLanguageCode(const QString &languageCode)
void setCodecForTr(const char *name)
Definition: metatranslator.h:91
TranslatorMessage find(const QByteArray &context, const QByteArray &sourceText, const QByteArray &comment) const
Definition: translator.h:152
void setCodec(const char *name)
QString languageCode() const
bool saveXLIFF(const MetaTranslator &mt, const QString &filename)
MetaTranslator & operator=(const MetaTranslator &tor)
void stripEmptyContexts()
void insert(const TranslatorMessage &m)
QByteArray codecName
Definition: metatranslator.h:111
static QStringList normalizedTranslations(const TranslatorMessage &m, QLocale::Language lang, QLocale::Country country)
Definition: metatranslator.h:54
QMap< int, TranslatorMessage > TMMInv
Definition: metatranslator.h:106
QString m_language
Definition: metatranslator.h:125
QTextCodec * codecForTr() const
Definition: metatranslator.h:92
SaveMode
Definition: translator.h:152
bool load(const QString &filename)
bool saveXLIFF(const QString &filename) const
bool release(const QString &filename, bool verbose=false, bool ignoreUnfinished=false, Translator::SaveMode mode=Translator::Stripped) const
QMap< TranslatorMessage, int > TMM
Definition: metatranslator.h:105
QList< TranslatorMessage > messages() const
Definition: qxml.h:311
const char int mode
Definition: ioapi.h:38
bool contains(const QByteArray &context, const QByteArray &sourceText, const QByteArray &comment) const
QString toUnicode(const char *str, bool utf8) const
Definition: translator.h:58
TMM mm
Definition: metatranslator.h:110
Definition: translator.h:60
QXmlErrorHandler * xmlErrorHandler
Definition: metatranslator.h:114
bool saveTS(const QString &filename) const
static int grammaticalNumerus(QLocale::Language language, QLocale::Country country)
static void languageAndCountry(const QString &languageCode, QLocale::Language *lang, QLocale::Country *country)
void makeFileNamesAbsolute()
void setXmlErrorHandler(QXmlErrorHandler *handler)
Definition: metatranslator.h:89
QDir m_originalPath
Definition: metatranslator.h:113
QList< TranslatorMessage > translatedMessages() const
void stripIdenticalSourceTranslations()

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)