diff options
author | Mert Tumer <mert.tumer@collabora.com> | 2022-07-05 12:03:27 +0300 |
---|---|---|
committer | Mert Tumer <mert.tumer@collabora.com> | 2022-09-13 00:02:16 +0200 |
commit | f0b4db7355cffa1f22ed5063db829b1f1f285a72 (patch) | |
tree | cb42d1443c05b3f789c70de29d5f25c7605b09b3 /sw/inc | |
parent | d896ad282b6d09666b87442863c2de9ac06daa06 (diff) |
new uno command uno:Translate with deepl api
New Uno command added for translation
right now it is only using deepl translation api
There's a section in the options > language settings
for setting up the api url and auth key
uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.
DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.
Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection
Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137199
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sw/inc/swabstdlg.hxx | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index 25d518d58def..5748ba7122ff 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -299,6 +299,7 @@ #define STR_DELETE_NOTE_AUTHOR NC_("STR_DELETE_NOTE_AUTHOR", "Delete ~All Comments by $1") #define STR_HIDE_NOTE_AUTHOR NC_("STR_HIDE_NOTE_AUTHOR", "H~ide All Comments by $1") #define STR_OUTLINE_NUMBERING NC_("STR_OUTLINE_NUMBERING", "Chapter Numbering") +#define STR_STATSTR_SWTRANSLATE NC_("STR_STATSTR_SWTRANSLATE", "Translating document...") /* To translators: $1 == will be replaced by STR_WORDCOUNT_WORDARG, and $2 by STR_WORDCOUNT_COLARG e.g. Selected: 1 word, 2 characters */ #define STR_WORDCOUNT NC_("STR_WORDCOUNT", "Selected: $1, $2") diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 0963de35da21..a841ce5d0ffd 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -375,6 +375,18 @@ public: virtual sal_uInt16 GetRestartPage() const = 0; }; +class SwLanguageListItem; + +class AbstractSwTranslateLangSelectDlg +{ +protected: + virtual ~AbstractSwTranslateLangSelectDlg() = default; +public: + virtual std::shared_ptr<weld::DialogController> getDialogController() = 0; + virtual std::optional<SwLanguageListItem> GetSelectedLanguage() = 0; +}; + + class SwAbstractDialogFactory { public: @@ -398,6 +410,7 @@ public: CreateSwContentControlListItemDlg(weld::Window* pParent, SwContentControlListItem& rItem) = 0; virtual std::shared_ptr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) = 0; + virtual std::shared_ptr<AbstractSwTranslateLangSelectDlg> CreateSwTranslateLangSelectDlg(weld::Window *pParent, SwWrtShell &rSh) = 0; virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(weld::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet, SwCharDlgMode nDialogMode, const OUString* pFormatStr = nullptr) = 0; |