Skip to content

Commit

Permalink
Better messages if source language is unknown
Browse files Browse the repository at this point in the history
As a follow-up to 2d62116, differentiate the two cases when
pre-translation can't be done: use of symbolic IDs and unknown source
language. Provide separate explanations for both.
  • Loading branch information
vslavik committed Aug 1, 2023
1 parent 8034c28 commit 1338bc2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/pretranslate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int PreTranslateCatalog(wxWindow *window, CatalogPtr catalog, const PreTranslate

void PreTranslateWithUI(wxWindow *window, PoeditListCtrl *list, CatalogPtr catalog, std::function<void()> onChangesMade)
{
if (catalog->UsesSymbolicIDsForSource() || !catalog->GetSourceLanguage().IsValid())
if (catalog->UsesSymbolicIDsForSource())
{
wxWindowPtr<wxMessageDialog> resultsDlg(
new wxMessageDialog
Expand All @@ -166,6 +166,21 @@ void PreTranslateWithUI(wxWindow *window, PoeditListCtrl *list, CatalogPtr catal
resultsDlg->ShowWindowModalThenDo([resultsDlg](int){});
return;
}
else if (!catalog->GetSourceLanguage().IsValid())
{
wxWindowPtr<wxMessageDialog> resultsDlg(
new wxMessageDialog
(
window,
_("Cannot pre-translate from unknown language."),
_("Pre-translate"),
wxOK | wxICON_ERROR
)
);
resultsDlg->SetExtendedMessage(_(L"Pre-translation requires that source text’s language is known. Poedit couldn’t detect it in this file."));
resultsDlg->ShowWindowModalThenDo([resultsDlg](int){});
return;
}

wxWindowPtr<wxDialog> dlg(new wxDialog(window, wxID_ANY, _("Pre-translate"), wxDefaultPosition, wxSize(PX(440), -1)));
auto topsizer = new wxBoxSizer(wxVERTICAL);
Expand Down
7 changes: 6 additions & 1 deletion src/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,16 @@ void SuggestionsSidebarBlock::UpdateSuggestionsForItem(CatalogItemPtr item)
m_pendingQueries = 0;

// FIXME: Get catalog info from `item` once present there
if (m_parent->GetCatalog()->UsesSymbolicIDsForSource() || !m_parent->GetCatalog()->GetSourceLanguage().IsValid())
if (m_parent->GetCatalog()->UsesSymbolicIDsForSource())
{
SetMessage("SuggestionErrorTemplate", _(L"Translation suggestions require that source text is available. They don’t work if only IDs without the actual text are used."));
return;
}
else if (!m_parent->GetCatalog()->GetSourceLanguage().IsValid())
{
SetMessage("SuggestionErrorTemplate", _(L"Translation suggestions require that source text’s language is known. Poedit couldn’t detect it in this file."));
return;
}

auto srclang = m_parent->GetCurrentSourceLanguage();
auto lang = m_parent->GetCurrentLanguage();
Expand Down

0 comments on commit 1338bc2

Please sign in to comment.