diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-16 12:55:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-09-17 17:17:39 +0200 |
commit | 1f9d39b4b518eb6316d822c63d7b9b456de9e1c0 (patch) | |
tree | 92db2c09492e96ebc4e6bc4970e0c88230d48352 /desktop | |
parent | 0bf27ee5226496f844361e2c8cc0fbf625ec1466 (diff) |
Output what languages are handled by LanguageTool
to explain the absence of languages that are listed by 'Preloading'
because the languages handled by a remote LanguageTool are removed
from the languages handled with local data.
Change-Id: I203657f68a7b9399e39ebf9ab9447c7ae56efe68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173448
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
(cherry picked from commit c5fc86e770901eb90356cb31d4ac71ac7dad9ce6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173538
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index cf6088164730..6a23f17911f2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1020,8 +1020,10 @@ void hideSidebar() SetLastExceptionMsg(u"No view shell or sidebar"_ustr); } -void setLanguageToolConfig() +css::uno::Sequence<css::lang::Locale> setLanguageToolConfig() { + css::uno::Sequence<css::lang::Locale> aLTLocales; + const char* pEnabled = ::getenv("LANGUAGETOOL_ENABLED"); const char* pBaseUrlString = ::getenv("LANGUAGETOOL_BASEURL"); @@ -1034,7 +1036,7 @@ void setLanguageToolConfig() OUString aEnabled = OStringToOUString(pEnabled, RTL_TEXTENCODING_UTF8); if (aEnabled != "true") - return; + return aLTLocales; OUString aBaseUrl = OStringToOUString(pBaseUrlString, RTL_TEXTENCODING_UTF8); try { @@ -1062,6 +1064,11 @@ void setLanguageToolConfig() } batch->commit(); + uno::Reference<linguistic2::XProofreader> xGC( + xContext->getServiceManager()->createInstanceWithContext(u"org.openoffice.lingu.LanguageToolGrammarChecker"_ustr, xContext), + uno::UNO_QUERY_THROW); + uno::Reference<linguistic2::XSupportedLocales> xSuppLoc(xGC, uno::UNO_QUERY_THROW); + css::uno::Reference<css::linguistic2::XLinguServiceManager2> xLangSrv = css::linguistic2::LinguServiceManager::create(xContext); if (xLangSrv.is()) @@ -1072,11 +1079,6 @@ void setLanguageToolConfig() Sequence<OUString> aEmpty; Sequence<css::lang::Locale> aLocales = xSpell->getLocales(); - uno::Reference<linguistic2::XProofreader> xGC( - xContext->getServiceManager()->createInstanceWithContext(u"org.openoffice.lingu.LanguageToolGrammarChecker"_ustr, xContext), - uno::UNO_QUERY_THROW); - uno::Reference<linguistic2::XSupportedLocales> xSuppLoc(xGC, uno::UNO_QUERY_THROW); - for (int itLocale = 0; itLocale < aLocales.getLength(); itLocale++) { // turn off spell checker if LanguageTool supports the locale already @@ -1086,12 +1088,16 @@ void setLanguageToolConfig() } } } + + aLTLocales = xSuppLoc->getLocales(); } catch(uno::Exception const& rException) { SAL_WARN("lok", "Failed to set LanguageTool API settings: " << rException.Message); } } + + return aLTLocales; } } // end anonymous namespace @@ -7900,7 +7906,14 @@ static void preloadData() std::cerr << "\n"; // setup LanguageTool config before spell checking init - setLanguageToolConfig(); + css::uno::Sequence<css::lang::Locale> aLTLocales = setLanguageToolConfig(); + if (aLTLocales.getLength()) + { + std::cerr << "Remote linguistic service languages: "; + for (auto &it : std::as_const(aLTLocales)) + std::cerr << LanguageTag::convertToBcp47(it) << " "; + std::cerr << "\n"; + } // preload all available dictionaries linguistic2::DictionaryList::create(comphelper::getProcessComponentContext()); @@ -7908,7 +7921,7 @@ static void preloadData() css::linguistic2::LinguServiceManager::create(comphelper::getProcessComponentContext()); css::uno::Reference<linguistic2::XSpellChecker> xSpellChecker(xLngSvcMgr->getSpellChecker()); - std::cerr << "Preloading dictionaries: "; + std::cerr << "Preloading local dictionaries: "; css::uno::Reference<linguistic2::XSupportedLocales> xSpellLocales(xSpellChecker, css::uno::UNO_QUERY_THROW); uno::Sequence< css::lang::Locale > aLocales = xSpellLocales->getLocales(); for (auto& it : aLocales) @@ -7931,7 +7944,7 @@ static void preloadData() css::uno::Reference<linguistic2::XThesaurus> xThesaurus(xLngSvcMgr->getThesaurus()); css::uno::Reference<linguistic2::XSupportedLocales> xThesLocales(xSpellChecker, css::uno::UNO_QUERY_THROW); aLocales = xThesLocales->getLocales(); - std::cerr << "Preloading thesauri: "; + std::cerr << "Preloading local thesauri: "; for (auto& it : aLocales) { std::cerr << LanguageTag::convertToBcp47(it) << " "; |