重要的
該計畫已遷移到 KDE 保護傘下,開發將在 https://invent.kde.org/office/crow-translate 上繼續。
Crow Translate是一款用C++ / Qt編寫的簡單輕量級翻譯器,可讓您使用 Google、Yandex、Bing、LibreTranslate 和 Lingva 翻譯 API 翻譯和朗讀文字。您可能也對該專案中使用的我的庫 QOnlineTranslator 感興趣。
電漿
電漿手機
Windows 10
您可以在設定中更改它們。由於作業系統限制,某些按鍵序列可能無法使用。
Wayland 不支援全域快捷方式註冊,但您可以使用 D-Bus 在系統設定中綁定操作。對於支援其他應用程式操作的桌面環境(例如 KDE),您將看到它們在系統捷徑設定中預先定義。您也可以將它們用於 X11 會話,但您需要在應用程式設定中停用全域捷徑註冊以避免衝突。
鑰匙 | 描述 |
---|---|
Ctrl + Alt + E | 翻譯選定的文本 |
Ctrl + Alt + S | 朗讀選定的文本 |
Ctrl + Alt + F | 說出所選文字的翻譯 |
Ctrl + Alt + G | 停止說話 |
Ctrl + Alt + C | 顯示主視窗 |
Ctrl + Alt + I | 識別螢幕區域中的文字 |
Ctrl + Alt + O | 翻譯螢幕區中的文字 |
鑰匙 | 描述 |
---|---|
Ctrl +返回 | 翻譯 |
Ctrl + R | 交換語言 |
Ctrl + Q | 關閉視窗 |
Ctrl + S | 朗讀來源/暫停文字朗讀 |
Ctrl + Shift + S | 朗讀翻譯/暫停文字朗讀 |
Ctrl + Shift + C | 將翻譯複製到剪貼簿 |
該程式還有一個控制台介面。
用法: crow [options] text
選項 | 描述 |
---|---|
-h, --help | 顯示幫助 |
-v, --version | 顯示版本訊息 |
-c, --codes | 顯示語言代碼 |
-s, --source <code> | 指定來源語言(預設情況下,引擎將嘗試自行確定語言) |
-t, --translation <code> | 指定翻譯語言,以“+”分隔(預設情況下,使用系統語言) |
-l, --locale <code> | 指定翻譯語言(預設使用系統語言) |
-e, --engine <engine> | 指定翻譯引擎('google'、'yandex'、'bing'、'libretranslate' 或 'lingva'),預設使用 Google |
-p, --speak-translation | 說出翻譯 |
-u, --speak-source | 講出源頭 |
-f, --file | 從文件中讀取來源文字。參數將被解釋為檔案路徑 |
-i, --stdin | 將標準輸入資料新增至來源文字 |
-a, --audio-only | 使用--speak-translation 或--speak-source 時僅列印講話文本 |
-b, --brief | 僅列印翻譯 |
-j, --json | 列印輸出格式為 JSON |
注意:如果不將啟動參數傳遞給程序,GUI 將啟動。
io.crow_translate.CrowTranslate
├── /io/crow_translate/CrowTranslate/Ocr
| └── method void io.crow_translate.CrowTranslate.Ocr.setParameters(QVariantMap parameters);
└── /io/crow_translate/CrowTranslate/MainWindow
| # Global shortcuts
├── method void io.crow_translate.CrowTranslate.MainWindow.translateSelection();
├── method void io.crow_translate.CrowTranslate.MainWindow.speakSelection();
├── method void io.crow_translate.CrowTranslate.MainWindow.speakTranslatedSelection();
├── method void io.crow_translate.CrowTranslate.MainWindow.playPauseSpeaking();
├── method void io.crow_translate.CrowTranslate.MainWindow.stopSpeaking();
├── method void io.crow_translate.CrowTranslate.MainWindow.open();
├── method void io.crow_translate.CrowTranslate.MainWindow.copyTranslatedSelection();
├── method void io.crow_translate.CrowTranslate.MainWindow.recognizeScreenArea();
├── method void io.crow_translate.CrowTranslate.MainWindow.translateScreenArea();
├── method void io.crow_translate.CrowTranslate.MainWindow.delayedRecognizeScreenArea();
├── method void io.crow_translate.CrowTranslate.MainWindow.delayedTranslateScreenArea();
| # Main window shortcuts
├── method void io.crow_translate.CrowTranslate.MainWindow.clearText();
├── method void io.crow_translate.CrowTranslate.MainWindow.cancelOperation();
├── method void io.crow_translate.CrowTranslate.MainWindow.swapLanguages();
├── method void io.crow_translate.CrowTranslate.MainWindow.openSettings();
├── method void io.crow_translate.CrowTranslate.MainWindow.setAutoTranslateEnabled(bool enabled);
├── method void io.crow_translate.CrowTranslate.MainWindow.copySourceText();
├── method void io.crow_translate.CrowTranslate.MainWindow.copyTranslation();
├── method void io.crow_translate.CrowTranslate.MainWindow.copyAllTranslationInfo();
└── method void io.crow_translate.CrowTranslate.MainWindow.quit();
例如,您可以使用dbus-send
顯示主視窗:
dbus-send --type=method_call --dest=io.crow_translate.CrowTranslate /io/crow_translate/CrowTranslate/MainWindow io.crow_translate.CrowTranslate.MainWindow.open
或透過qdbus
:
qdbus io.crow_translate.CrowTranslate /io/crow_translate/CrowTranslate/MainWindow io.crow_translate.CrowTranslate.MainWindow.open
# or shorter
qdbus io.crow_translate.CrowTranslate /io/crow_translate/CrowTranslate/MainWindow open
Wayland不提供全域捷徑的API,需要您自行註冊。
KDE 有一個方便的功能,可以在 .desktop 檔案中定義捷徑並將其匯入設定中。這些快捷方式已啟用並且預設應該可以使用。
對於 GNOME,您需要手動將 D-Bus 命令設定為全域快捷方式。例如,要翻譯選取的文本,請使用以下命令:
qdbus io.crow_translate.CrowTranslate /io/crow_translate/CrowTranslate/MainWindow translateSelection
您可以在 GNOME 系統設定中為此指令設定熱鍵。
此專案使用以下外部函式庫,其中包含作為 git 子模組:
Fluent 圖示主題捆綁在一起,提供 Windows 上的圖示和 Linux 上的後備圖示。
圓形標誌圖示用於標誌。
可在發布頁面下載。另請查看網站以了解其他安裝方法。
注意:在 Linux 上,要讓應用程式在非 KDE 桌面環境中看起來是本機的,您需要設定 Qt 應用程式樣式。這可以透過使用 qt5ct 或 adwaita-qt5 或 qtstyleplugins 來完成。請檢查適合您的發行版的安裝指南。
注意: Windows 需要 Microsoft Visual C++ Redistributable 2019 才能運作。
您可以使用以下命令建置Crow Translate :
mkdir build
cd build
cmake .. # Or `cmake -D CMAKE_BUILD_TYPE=Release ..` for single-configuration generators such as Ninja or GNU Make
cmake --build . # Or `cmake --build . --config Release` for multi-config generators such as Visual Studio Generators or Xcode
然後您將獲得一個名為crow
的二進位檔案。
CMake可以自動建立指定的套件類型。
如果您使用 Makefile、Ninja 或 Xcode 產生器,您可以使用套件目標:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CPACK_GENERATOR=DEB .. # You can specify several types of packages separated by semicolons in double quotes, for example: `CPACK_GENERATOR="DEB;ZIP;NSIS"`
cmake --build . --target package
或者您可以對任何生成器使用 CPack 實用程式:
mkdir build
cd build
cmake .. # Or `cmake -D CMAKE_BUILD_TYPE=Release ..` for single-configuration generators such as Ninja or GNU Make
cpack -G DEB # Or `cpack -G DEB -C Release` for multi-config generators such as Visual Studio Generators or Xcode
在 Windows 上,您需要 VCPKG 來捆綁所有必需的 DLL。
WITH_PORTABLE_MODE
- 啟用便攜式功能。如果您在應用程式資料夾中建立名為settings.ini
的文件,Crow 會將配置儲存在其中。它還在應用程式設定中添加了“便攜式模式”選項,其作用相同。WITH_KWAYLAND
- 尋找並使用 KWayland 庫以實現更好的 Wayland 整合。建置參數在配置階段傳遞: cmake -D WITH_PORTABLE_MODE ..
。
為了幫助在地化,您可以使用 Crowdin 或直接使用 Qt Linguist 翻譯data/translations
中的檔案。要新增語言,請在 Crowdin 頁面上寫信給我或將data/translations/crow-translate.ts
複製到data/translations/crow-translate_<ISO 639-1 language code>_<ISO 3166-1 country code>.ts
,翻譯它並發送拉取請求。