⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtranslator.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QTranslator 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTranslator \- .PP\fC#include <qtranslator.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQTranslator\fR ( QObject * parent, const char * name = 0 )".br.ti -1c.BI "\fB~QTranslator\fR ()".br.ti -1c.BI "QString find ( const char * context, const char * sourceText, const char * comment = 0 ) const  \fI(obsolete)\fR".br.ti -1c.BI "virtual QTranslatorMessage \fBfindMessage\fR ( const char * context, const char * sourceText, const char * comment ) const".br.ti -1c.BI "bool \fBload\fR ( const QString & filename, const QString & directory = QString::null, const QString & search_delimiters = QString::null, const QString & suffix = QString::null )".br.ti -1c.BI "void \fBclear\fR ()".br.ti -1c.BI "enum \fBSaveMode\fR { Everything, Stripped }".br.ti -1c.BI "bool \fBsave\fR ( const QString & filename, SaveMode mode = Everything )".br.ti -1c.BI "void \fBinsert\fR ( const QTranslatorMessage & message )".br.ti -1c.BI "void insert ( const char * context, const char * sourceText, const QString & translation )  \fI(obsolete)\fR".br.ti -1c.BI "void \fBremove\fR ( const QTranslatorMessage & message )".br.ti -1c.BI "void remove ( const char * context, const char * sourceText )  \fI(obsolete)\fR".br.ti -1c.BI "bool \fBcontains\fR ( const char * context, const char * sourceText, const char * comment = 0 ) const".br.ti -1c.BI "void \fBsqueeze\fR ( SaveMode mode = Everything )".br.ti -1c.BI "void \fBunsqueeze\fR ()".br.ti -1c.BI "QValueList<QTranslatorMessage> \fBmessages\fR () const".br.in -1c.SH DESCRIPTIONThe QTranslator class provides internationalization support for text output..PPAn object of this class contains a set of QTranslatorMessage objects, each of which specifies a translation from a source language to a target language. QTranslator provides functions to look up such translations, add new ones, remove them, load and save them, etc..PPThe most common use of QTranslator is expected to be loading a translator file made using Qt Linguist, installing it using QApplication::installTranslator(), and using it via QObject::tr(), like this:.PP.nf.br  int main( int argc, char ** argv ).br  {.br      QApplication app( argc, argv );.br.br      QTranslator translator( 0 );.br      translator.load( "french.qm", "." );.br      app.installTranslator( &translator );.br.br      MyWidget m;.br      app.setMainWidget( &m );.br      m.show();.br.br      return app.exec();.br  }.br.fi.PPMost applications will never need to do anything else with this class. However, applications that work on translator files need the other functions in this class..PPIt is possible to do lookup using findMessage() (as tr() and QApplication::translate() do) and contains(), insert a new translation message using insert(), and remove it using remove()..PPBecause end-user programs and translation tools have rather different requirements, QTranslator can use stripped translator files in a way that uses a minimum of memory and provides very little functionality other than findMessage()..PPThus, load() may not load enough information to make anything more than findMessage() work. save() has an argument indicating whether to save just this minimum of information or to save everything..PP"Everything" means that for each translation item the following information is kept:.TPThe \fItranslated text\fR - the return value from tr()..TPThe input key:.TPThe \fIsource text\fR - usually the argument to tr()..TPThe \fIcontext\fR - usually the class name for the tr() caller..TPThe \fIcomment\fR - a comment that helps disambiguate different uses of the same text in the same context..PPThe minimum for each item is just the information necessary for findMessage() to return the right text. This may include the source, context and comment, but usually it is just a hash value and the translated text..PPFor example, the "Cancel" in a dialog might have "Anuluj" when the program runs in Polish (in this case the source text would be" Cancel"). The context would (normally) be the dialog's class name; there would normally be no comment, and the translated text would be" Anuluj"..PPBut it's not always so simple. The Spanish version of a printer dialog with settings for two-sided printing and binding would probably require both "Activado" and "Activada" as translations for" Enabled". In this case the source text would be "Enabled" in both cases and the context would be the dialog's class name, but the two items would have disambiguating comments such as "two-sided printing" for one and "binding" for the other. The comment enables the translator to choose the appropriate gender for the Spanish version, and enables Qt to distinguish between translations..PPNote that when QTranslator loads a stripped file, most functions do not work. The functions that do work with stripped files are explicitly documented as such..PPSee also QTranslatorMessage, QApplication::installTranslator(), QApplication::removeTranslator(), QObject::tr(), QApplication::translate(), Environment Classes and Internationalization with Qt..SS "Member Type Documentation".SH "QTranslator::SaveMode"This enum type defines how QTranslator can write translation files. There are two modes:.TP\fCQTranslator::Everything\fR - files are saved with all contents.TP\fCQTranslator::Stripped\fR - files are saved with just what's needed for end-users.PPNote that when QTranslator loads a stripped file, most functions do not work. The functions that do work with stripped files are explicitly documented as such..SH MEMBER FUNCTION DOCUMENTATION.SH "QTranslator::QTranslator ( QObject * parent, const char * name = 0 )"Constructs an empty message file object that is not connected to any file. The object has parent \fIparent\fR and name \fIname\fR..SH "QTranslator::~QTranslator ()"Destroys the object and frees any allocated resources..SH "void QTranslator::clear ()"Empties this translator of all contents..PPThis function works with stripped translator files..SH "bool QTranslator::contains ( const char * context, const char * sourceText, const char * comment = 0 ) const"Returns TRUE if this message file contains a message with the key (\fIcontext\fR, \fIsourceText\fR, \fIcomment\fR); otherwise returns FALSE..PPThis function works with stripped translator files..PP(This is is a one-liner that calls find().).SH "QString QTranslator::find ( const char * context, const char * sourceText, const char * comment = 0 ) const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPPlease use findMessage() instead..PPReturns the translation for the key (\fIcontext\fR, \fIsourceText\fR, \fIcomment\fR) or QString::null if there is none in this translator..SH "QTranslatorMessage QTranslator::findMessage ( const char * context, const char * sourceText, const char * comment ) const\fC [virtual]\fR"Returns the QTranslatorMessage for the key (\fIcontext\fR, \fIsourceText\fR, \fIcomment\fR)..SH "void QTranslator::insert ( const QTranslatorMessage & message )"Inserts \fImessage\fR into this message file..PPThis function does \fInot\fR work with stripped translator files. It may seem to, but that is not dependable..PPSee also remove()..SH "void QTranslator::insert ( const char * context, const char * sourceText, const QString & translation )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..SH "bool QTranslator::load ( const QString & filename, const QString & directory = QString::null, const QString & search_delimiters = QString::null, const QString & suffix = QString::null )"Loads \fIfilename\fR, which may be an absolute file name or relative to \fIdirectory\fR. The previous contents of this translator object is discarded..PPIf the full file name does not exist, other file names are tried in the following order:.PP<ol type=1>.TPFile name with \fIsuffix\fR appended (".qm" if the suffix is QString::null)..TPFile name with text after a character in \fIsearch_delimiters\fR stripped ("_." is the default for \fIsearch_delimiters\fR if it is QString::null)..TPFile name stripped and \fIsuffix\fR appended..TPFile name stripped further, etc..PPFor example, an application running in the fr_CA locale (French-speaking Canada) might call load("foo.fr_ca", "/opt/foolib"), which would then try to open these files:.PP<ol type=1>.TP/opt/foolib/foo.fr_ca.TP/opt/foolib/foo.fr_ca.qm.TP/opt/foolib/foo.fr.TP/opt/foolib/foo.fr.qm.TP/opt/foolib/foo.TP/opt/foolib/foo.qm.PPSee also save()..PPExample: i18n/main.cpp..SH "QValueList<QTranslatorMessage> QTranslator::messages () const"Returns a list of the messages in the translator. This function is rather slow; because it is seldom called, it's optimized for simplicity and small size, not speed..SH "void QTranslator::remove ( const QTranslatorMessage & message )"Removes \fImessage\fR from this translator..PPThis function works with stripped translator files..PPSee also insert()..SH "void QTranslator::remove ( const char * context, const char * sourceText )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPRemoves the translation associated to the key (\fIcontext\fR, \fIsourceText\fR," ") from this translator..SH "bool QTranslator::save ( const QString & filename, SaveMode mode = Everything )"Saves this message file to \fIfilename\fR, overwriting the previous contents of \fIfilename\fR. If \fImode\fR is Everything (the default), all the information is preserved. If \fImode\fR is Stripped, any information that is not necessary for findMessage() is stripped away..PPSee also load()..SH "void QTranslator::squeeze ( SaveMode mode = Everything )"Converts this message file to the compact format used to store message files on disk..PPYou should never need to call this directly; save() and other functions call it as necessary. \fImode\fR is for internal use..PPSee also save() and unsqueeze()..SH "void QTranslator::unsqueeze ()"Converts this message file into an easily modifiable data structure, less compact than the format used in the files..PPYou should never need to call this function; it is called by insert() and friends as necessary..PPSee also squeeze()..SH "SEE ALSO".BR http://doc.trolltech.com/qtranslator.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qtranslator.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -