<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # QTranslator Class Reference ## [[QtCore](index.htm) module] 該QTranslator這樣類提供了文本輸出的國際化支持。[More...](#details) 繼承[QObject](qobject.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `bool isEmpty (self)` * `bool load (self, QString?fileName, QString?directory?=?QString(), QString?searchDelimiters?=?QString(), QString?suffix?=?QString())` * `bool load (self, QLocale?locale, QString?fileName, QString?prefix?=?QString(), QString?directory?=?QString(), QString?suffix?=?QString())` * `bool loadFromData (self, str?data)` * `QString translate (self, str?context, str?sourceText, str?disambiguation?=?None)` * `QString translate (self, str?context, str?sourceText, str?comment, int?n)` * * * ## Detailed Description 該QTranslator這樣類提供了文本輸出的國際化支持。 這個類的一個對象包含了一組從源語言翻譯成目標語言的。 QTranslator這樣提供的功能來查找在翻譯文件翻譯。使用創建翻譯文件[Qt Linguist](index.htm#qt-linguist)。 最常見的用途QTranslator這樣的是:它使用加載翻譯文件,安裝[QApplication.installTranslator](qcoreapplication.html#installTranslator)() ,并通過用它[QObject.tr](qobject.html#tr)( ) 。這里的`main()`從功能上[Hello tr()](index.htm)例如: ``` int main(int argc, char *argv[]) { [QApplication](qapplication.html) app(argc, argv); QTranslator translator; translator.load("hellotr_la"); app.installTranslator(&translator); [QPushButton](qpushbutton.html) hello([QPushButton](qpushbutton.html).tr("Hello world!")); hello.resize(100, 30); hello.show(); return app.exec(); } ``` 需要注意的是,譯者必須創建_before_應用程序的窗口小部件。 大多數應用程序都不需要做任何事情都要有這個類。這個類提供的其他功能是對翻譯文件的工作應用中非常有用。 ### Looking up Translations 它可以利用查找翻譯[translate](qtranslator.html#translate)( ) (如[tr](qobject.html#tr)()和[QApplication.translate](qcoreapplication.html#translate)( )一樣) 。該[translate](qtranslator.html#translate)( )函數需要三個參數: * The _context_ - usually the class name for the [tr](qobject.html#tr)() caller. * The _source text_ - usually the argument to [tr](qobject.html#tr)(). * The _disambiguation_ - an optional string that helps disambiguate different uses of the same text in the same context. 例如,在一個對話框“取消”可能具有“ Anuluj ”時,程序在波蘭的運行(在這種情況下,源文本將是“取消” ) 。上下文將(通常)是對話框的類名;有一般會是沒有意見,而翻譯的文本將是“ Anuluj ” 。 但它并不總是那么簡單。打印機對話框中的設定進行雙面打印和裝訂的西班牙語版本可能會同時需要“ Activado ”和“ Activada ”作為翻譯為“??已啟用” 。在這種情況下,源文本將在這兩種情況下“啟用” ,并在上下文將是對話框的類名,但是這兩個項目將有disambiguations如“雙面打印”為1與“結合”,為其他。消歧使譯者選擇適當的性別為西班牙語版本,使Qt的翻譯來區分。 ### Using Multiple Translations 多個翻譯文件可以安裝在一個應用程序。翻譯是在它們被安裝在其相反的順序搜索的,所以最近安裝的翻譯文件中搜索翻譯第一和最早的翻譯文件最后搜索。搜索一旦被發現包含匹配的字符串翻譯停止。 這種機制使得它可以為特定的翻譯被“選中”或優先于他人,只需通過它傳遞給從應用程序卸載翻譯[QApplication.removeTranslator](qcoreapplication.html#removeTranslator)( )函數,并重新安裝[QApplication.installTranslator](qcoreapplication.html#installTranslator)( ) 。那么這將是第一次翻譯要查找的字符串匹配。 * * * ## Method Documentation ``` QTranslator.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個空消息文件對象的父_parent_未連接到任何文件。 ``` bool QTranslator.isEmpty (self) ``` 返回True如果翻譯為空,否則返回False 。此功能適用于剝離和未移除的翻譯文件。 ``` bool QTranslator.load (self, QString?fileName, QString?directory?=?QString(), QString?searchDelimiters?=?QString(), QString?suffix?=?QString()) ``` 負載_filename_+_suffix_( “ QM ”如果_suffix_未指定) ,其可以是絕對文件名或相對于_directory_。返回True如果加載成功的翻譯,否則返回False 。 If _directory_沒有被指定,應用程序的可執行文件的目錄時(即作為[applicationDirPath()](qcoreapplication.html#applicationDirPath)) 。 這個翻譯對象的以前的內容將被丟棄。 如果文件名不存在,其他的文件名嘗試按以下順序: 1. 文件名不_suffix_追加。 2. 文件名與一個字符之后的文字_search_delimiters_剝去( “[_](index.html)“是默認的_search_delimiters_如果它是一個空字符串)和_suffix_。 3. 沒有文件名剝離_suffix_追加。 4. 文件名再剝離等。 例如,在fr_CA語言環境中運行(法語加拿大)的應用程序可能調用的負載( “ foo.fr_ca ” , “ /選擇/ foolib ” ) 。 load()方法會然后嘗試從該列表中打開的第一個現有可讀的文件: 1. `/opt/foolib/foo.fr_ca.qm` 2. `/opt/foolib/foo.fr_ca` 3. `/opt/foolib/foo.fr.qm` 4. `/opt/foolib/foo.fr` 5. `/opt/foolib/foo.qm` 6. `/opt/foolib/foo` ``` bool QTranslator.load (self, QLocale?locale, QString?fileName, QString?prefix?=?QString(), QString?directory?=?QString(), QString?suffix?=?QString()) ``` 負載_filename_+_prefix_+[ui language name](qlocale.html#uiLanguages)+_suffix_( “ QM ”如果_suffix_未指定) ,其可以是絕對文件名或相對于_directory_。返回True如果加載成功的翻譯,否則返回False 。 這個翻譯對象的以前的內容將被丟棄。 如果文件名不存在,其他的文件名嘗試按以下順序: 1. 文件名不_suffix_追加。 2. 后文件與用戶界面語言部分名稱的“[_](index.html)“字符剝離和_suffix_。 3. 無剝離與用戶界面語言部分文件名_suffix_追加。 4. 與用戶界面語言部分文件名再剝離等 例如,運行在語言環境下的應用程序[ui languages](qlocale.html#uiLanguages) - “上課” , “ FR- CA” , “德”可以稱之為負載([QLocale.system](qlocale.html#system)( ) , “富” , “ ” , “ /選擇/ foolib ” , “ QM ” ) 。[load](qtranslator.html#load)( )將取代' - ' (破折號)與'[_](index.html)' (下劃線)在UI語言,然后嘗試從該列表中打開的第一個現有可讀的文件: 1. `/opt/foolib/foo.es.qm` 2. `/opt/foolib/foo.es` 3. `/opt/foolib/foo.fr_CA.qm` 4. `/opt/foolib/foo.fr_CA` 5. `/opt/foolib/foo.de.qm` 6. `/opt/foolib/foo.de` 7. `/opt/foolib/foo.fr.qm` 8. `/opt/foolib/foo.fr` 9. `/opt/foolib/foo.qm` 10. `/opt/foolib/foo`。 11. `/opt/foolib/foo` 對操作系統所在的文件系統是大小寫敏感的,[QTranslator](qtranslator.html)也嘗試加載區域名稱的小寫版本。 此功能被引入Qt的4.8 。 ``` bool QTranslator.loadFromData (self, str?data) ``` ``` QString QTranslator.translate (self, str?context, str?sourceText, str?disambiguation?=?None) ``` 返回翻譯的關鍵(_context_,_sourceText_,_disambiguation_) 。如果沒有找到,還嘗試(_context_,_sourceText_,“”) 。如果仍然失敗,則返回一個空字符串。 如果您需要以編程方式插入翻譯中的[QTranslator](qtranslator.html)這個功能可以重新實現。 **See also** [load](qtranslator.html#load)( ) 。 ``` QString QTranslator.translate (self, str?context, str?sourceText, str?comment, int?n) ``` 這個函數的重載[translate](qtranslator.html#translate)( ) 。 返回翻譯的關鍵(_context_,_sourceText_,_disambiguation_) 。如果沒有找到,還嘗試(_context_,_sourceText_,“”) 。如果仍然失敗,則返回一個空字符串。 If _n_是不是-1 ,它是用來選擇的翻譯(例如“ % n文件中找到”與“ %不找到文件” )以適當的形式。 **See also** [load](qtranslator.html#load)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看