Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crowdin API v2, allow editing of any files as XLIFF #633

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2166b61
OAuth to new API v2
berezins Feb 25, 2020
fa3751c
Download and open file in Xliff
berezins May 8, 2020
e400607
Local path matches path in Crowdin
berezins Mar 19, 2020
50d4381
Upload file as XLIFF
berezins Mar 22, 2020
b4a90b7
OAuth to any organization or personal account
berezins Mar 28, 2020
750e76a
Fixed empty first and last name in organization user
berezins Apr 8, 2020
753a5c8
Hide assets from list
berezins Apr 8, 2020
8cdd4fe
Fix compilation errors on newer wxWidgets versions
berezins Apr 10, 2020
2139b6e
Crashed when to Save file deleted on Crowdin side
berezins Apr 10, 2020
68d5e5e
Crashed on open cached Crowdin file if logged out
berezins Apr 10, 2020
b202e3c
Leading slash in API requests removed
berezins May 20, 2020
e7161c0
Move AttachCloudSync() to GUI code
berezins May 20, 2020
a3c5c45
Hide 'Forbidden' projects
berezins Apr 17, 2020
caf7330
Domain agnostic file download
berezins Apr 17, 2020
ca4d693
Full path in file list including branch
berezins Apr 23, 2020
1f910e6
Implicit conversion from json to json_data
berezins Apr 26, 2020
e824933
Logging using wxLogTrace()
berezins May 14, 2020
99261b0
`std` explicitly
berezins May 7, 2020
de53022
Predominant `if`/`for`/`while` formatting
berezins May 17, 2020
8f6f90b
GetUserInfo() fixed
berezins May 21, 2020
e06429f
Native PO file support back
berezins May 22, 2020
98ab380
Buildable on Windows (wxStandardPaths())
berezins May 24, 2020
b5771a5
Buildable on macOS (wxGetHomeDir() undefined)
berezins May 24, 2020
f190355
OAuth: TM (translation memory) scope is not needed
berezins May 25, 2020
9b7a084
Removed auto approval of uploaded translations
berezins May 25, 2020
efb1a7d
XLF extension is XLIFF as well
berezins May 25, 2020
89ce540
Removed `importDuplicates`
berezins May 25, 2020
2b4649e
Logging improved (FileDownload, FileUpload)
berezins May 31, 2020
9a58ee3
Save/Sync for PO downloaded from Crowdin in browser
berezins May 31, 2020
4ab1146
Handle OAuth token upgrade from v1 API (2.3 Poedit)
berezins May 31, 2020
a046666
State in OAuth URL is auto-generated
berezins Jun 8, 2020
6f2d699
Use to_string_t() to bring wide/narrow match
berezins Jun 8, 2020
4b647ef
Update JSON C++ lib to fix MSVC compilation (temp)
vslavik May 9, 2020
32a15a9
Removed VS2019 JSON workarounds
berezins Jun 9, 2020
37a00fb
Few fixes to string literals
berezins Jun 9, 2020
a6788fa
Comments on catching errors in crowdin_http_client
berezins Jun 9, 2020
11f638e
Catalog::SerFileName() no longer needed to be virtual
berezins Jun 9, 2020
d2ea08f
cloud_sync.h is not needed anymore in catalog.h
berezins Jun 9, 2020
731c266
Reverted back occasionally removed empty line
berezins Jun 9, 2020
508e4f9
Twice-upload on "Sync" (with Crowdin) pressed fixed
berezins Jun 13, 2020
f7e6799
GCC: "error: operands to ?: have different types"
berezins Jun 13, 2020
d81778a
GetUserInfo() refactored and commented
berezins Jun 13, 2020
a37bb61
Comment for removing "Accept: application/json"
berezins Jun 13, 2020
9bc52ba
`mb_str()` to `str::to_utf8()` changed
berezins Jun 15, 2020
cc58929
Token domain error handling and logging
berezins Jun 15, 2020
0fa48dd
Removed moving unsupported files to the end
berezins Jun 15, 2020
1d244ec
Explicit `CmpNoCase() != 0` and comment
berezins Jun 15, 2020
6df545e
Save/sync PO downloaded via Crowdin UI improved
berezins Jun 18, 2020
a711235
Put together most of Crowdin stuff to IsFromCrowdin()
berezins Jun 18, 2020
0dcedfa
m_language is back in `XLIFFCatalog`
berezins Jun 18, 2020
0bb4cb4
Compilation fix for bSkipUpload
vslavik Jun 19, 2020
e9db2d0
Fix bad API URL prefix
vslavik Jun 20, 2020
579d3d4
Really open PO files natively, even if uploaded as POT
vslavik Jun 20, 2020
dced359
Fix broken IsFromCrowdin() logic
vslavik Jun 20, 2020
0f76785
New OAuth app since old Client ID compromised
berezins Jun 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions src/edframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ bool PoeditFrame::NeedsToAskIfCanDiscardCurrentDoc() const
}

template<typename TFunctor>
void PoeditFrame::DoIfCanDiscardCurrentDoc(TFunctor completionHandler)
void PoeditFrame::DoIfCanDiscardCurrentDoc(TFunctor completionHandler, bool bSkipUpload)
berezins marked this conversation as resolved.
Show resolved Hide resolved
{
if ( !NeedsToAskIfCanDiscardCurrentDoc() )
{
Expand All @@ -972,7 +972,7 @@ void PoeditFrame::DoIfCanDiscardCurrentDoc(TFunctor completionHandler)

wxWindowPtr<wxMessageDialog> dlg = CreateAskAboutSavingDialog();

dlg->ShowWindowModalThenDo([this,dlg,completionHandler](int retval) {
dlg->ShowWindowModalThenDo([this,dlg,completionHandler,bSkipUpload](int retval) {
// hide the dialog asap, WriteCatalog() may show another modal sheet
dlg->Hide();
#ifdef __WXOSX__
Expand All @@ -990,7 +990,7 @@ void PoeditFrame::DoIfCanDiscardCurrentDoc(TFunctor completionHandler)
WriteCatalog(fn, [=](bool saved){
if (saved)
completionHandler();
});
}, bSkipUpload);
};
if (!m_fileExistsOnDisk || GetFileName().empty())
GetSaveAsFilenameThenDo(m_catalog, doSaveFile);
Expand Down Expand Up @@ -1761,16 +1761,17 @@ void PoeditFrame::OnUpdateFromPOTUpdate(wxUpdateUIEvent& event)
#ifdef HAVE_HTTP_CLIENT
void PoeditFrame::OnUpdateFromCrowdin(wxCommandEvent&)
{
m_syncing = true;
DoIfCanDiscardCurrentDoc([=]{
CrowdinSyncFile(this, m_catalog, [=](std::shared_ptr<Catalog> cat){
m_catalog = cat;
EnsureAppropriateContentView();
NotifyCatalogChanged(m_catalog);
RefreshControls();
});
});
m_syncing = false;
});
}, true); // Set bSkipUpload to true to avoid twice upload of exactly same file with "Sync" button pressed once
// 1. DoIfCanDiscardCurrentDoc()=>WriteCatalog()=>CloudSyncProgressWindow::RunSync()=>CrowdinSyncDestination::Upload()=CrowdinClient::UploadFile()
// 2. <above lambda>=>CrowdinSyncFile()=>CrowdinClient::UploadFile()
// Otherwise reproducable with any file for which "Sync" (with Crowdin) button is active and pressed
}

void PoeditFrame::OnUpdateFromCrowdinUpdate(wxUpdateUIEvent& event)
Expand Down Expand Up @@ -2655,7 +2656,7 @@ void PoeditFrame::WriteCatalog(const wxString& catalog)
}

template<typename TFunctor>
void PoeditFrame::WriteCatalog(const wxString& catalog, TFunctor completionHandler)
void PoeditFrame::WriteCatalog(const wxString& catalog, TFunctor completionHandler, bool bSkipUpload)
{
wxBusyCursor bcur;

Expand Down Expand Up @@ -2714,17 +2715,11 @@ void PoeditFrame::WriteCatalog(const wxString& catalog, TFunctor completionHandl
if (ManagerFrame::Get())
ManagerFrame::Get()->NotifyFileChanged(GetFileName());

if(!m_catalog->GetCloudSync())
if(m_catalog->IsFromCrowdin())
m_catalog->AttachCloudSync(std::make_shared<CrowdinSyncDestination>());
if(!m_catalog->GetCloudSync() && m_catalog->IsFromCrowdin())
m_catalog->AttachCloudSync(std::make_shared<CrowdinSyncDestination>());

if (m_catalog->GetCloudSync())
// Avoid redundant upload during same call of
// OnUpdateFromCrowdin()=>
// 1. =>DoIfCanDiscardCurrentDoc()=>Upload()
// 2. =>CrowdinSyncFile()=>UploadFile()
if(!m_syncing)
CloudSyncProgressWindow::RunSync(this, m_catalog->GetCloudSync(), m_catalog);
if (!bSkipUpload && m_catalog->GetCloudSync())
CloudSyncProgressWindow::RunSync(this, m_catalog->GetCloudSync(), m_catalog);

if (tmUpdateThread.valid())
tmUpdateThread.wait();
Expand Down
5 changes: 2 additions & 3 deletions src/edframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PoeditFrame : public PoeditFrameBase
void WriteCatalog(const wxString& catalog);

template<typename TFunctor>
void WriteCatalog(const wxString& catalog, TFunctor completionHandler);
void WriteCatalog(const wxString& catalog, TFunctor completionHandler, bool bSkipUpload = false);

void FixDuplicatesIfPresent();
void WarnAboutLanguageIssues();
Expand Down Expand Up @@ -203,7 +203,7 @@ class PoeditFrame : public PoeditFrameBase
// if there's modified catalog, ask user to save it; return true
// if it's save to discard m_catalog and load new data
template<typename TFunctor>
void DoIfCanDiscardCurrentDoc(TFunctor completionHandler);
void DoIfCanDiscardCurrentDoc(TFunctor completionHandler, bool bSkipUpload = false);
bool NeedsToAskIfCanDiscardCurrentDoc() const;
wxWindowPtr<wxMessageDialog> CreateAskAboutSavingDialog();

Expand Down Expand Up @@ -379,7 +379,6 @@ class PoeditFrame : public PoeditFrameBase
bool m_hasObsoleteItems;
bool m_displayIDs;
bool m_setSashPositionsWhenMaximized;
bool m_syncing = false;
};


Expand Down