Skip to content

Commit

Permalink
Full path in file list including branch
Browse files Browse the repository at this point in the history
In dropdown list of "Open from Crowdin" dialog
  • Loading branch information
berezins committed Apr 23, 2020
1 parent e3f78d6 commit 6407583
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 51 deletions.
6 changes: 4 additions & 2 deletions Poedit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
POEDIT_FEATURES = "";
POEDIT_VERSION = 2.3;
POEDIT_VERSION = 2.4.10alpha;
SDKROOT = macosx;
WX_DEFINES = "__WXOSX_COCOA__ __WX__ __WXMAC_XCODE__=1 wxUSE_UNICODE_UTF8=0 wxUSE_UNICODE_WCHAR=1";
};
Expand Down Expand Up @@ -1839,7 +1839,7 @@
LLVM_LTO = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
POEDIT_FEATURES = "";
POEDIT_VERSION = 2.3;
POEDIT_VERSION = 2.4.10alpha;
SDKROOT = macosx;
WX_DEFINES = "__WXOSX_COCOA__ __WX__ __WXMAC_XCODE__=1 wxUSE_UNICODE_UTF8=0 wxUSE_UNICODE_WCHAR=1";
};
Expand All @@ -1856,6 +1856,7 @@
INFOPLIST_FILE = "$(SRCROOT)/macos/Poedit-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 2.4.10alpha;
OTHER_LDFLAGS = (
"-licuuc",
"-licudata",
Expand All @@ -1879,6 +1880,7 @@
INFOPLIST_FILE = "$(SRCROOT)/macos/Poedit-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 2.4.10alpha;
OTHER_LDFLAGS = (
"-licuuc",
"-licudata",
Expand Down
30 changes: 15 additions & 15 deletions macos/Poedit-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${POEDIT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -245,30 +245,30 @@
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeDescription</key>
<string>XML Localization Interchange File Format</string>
<key>UTTypeIconFile</key>
<string>XLIFF_Icon.icns</string>
<key>UTTypeIdentifier</key>
<string>org.oasis-open.xliff</string>
<key>UTTypeReferenceURL</key>
<string>http://docs.oasis-open.org/xliff/xliff-core/xliff-core.html</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.mime-type</key>
<array>
<string>application/x-xliff+xml</string>
</array>
<key>public.filename-extension</key>
<array>
<string>xliff</string>
<string>xlf</string>
</array>
<key>public.mime-type</key>
<array>
<string>application/x-xliff+xml</string>
</array>
</dict>
<key>UTTypeIconFile</key>
<string>XLIFF_Icon.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeDescription</key>
<string>XML Localization Interchange File Format</string>
<key>UTTypeReferenceURL</key>
<string>http://docs.oasis-open.org/xliff/xliff-core/xliff-core.html</string>
</dict>
</array>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: poedit
version: "2.4.7dev"
version: "2.4.10alpha"
summary: Simple translation editor
description: >
Translation editor for gettext (PO files) and XLIFF.
Expand Down
122 changes: 94 additions & 28 deletions src/crowdin_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@

#include <functional>
#include <mutex>
#include <stack>
#include <iostream>
#include <ctime>

#include <boost/algorithm/string.hpp>
#include <jwt-cpp/jwt.h>

#include <wx/translation.h>
#include <wx/utils.h>

#include <iostream>
#include <ctime>

class _M_get_result;
using namespace std;

Expand Down Expand Up @@ -261,7 +262,7 @@ dispatch::future<std::vector<CrowdinClient::ProjectListing>> CrowdinClient::GetU
{
cout << "\n\nGot projects: " << r << endl<<endl;
std::vector<ProjectListing> all;
for (auto&& d : r["data"])
for (const auto& d : r["data"])
{
const json& i = d["data"];
auto itPublicDownloads = i.find("publicDownloads");
Expand Down Expand Up @@ -289,32 +290,97 @@ dispatch::future<std::vector<CrowdinClient::ProjectListing>> CrowdinClient::GetU
dispatch::future<CrowdinClient::ProjectInfo> CrowdinClient::GetProjectInfo(const int project_id)
{
auto url = "projects/" + std::to_string(project_id);
return RefreshToken().then([=] () {
return m_api->get(url)
.then([this, url](json r)
{
ProjectInfo prj;
const json& d = r["data"];
prj.name = str::to_wstring(d["name"]);
prj.id = d["id"];
for (auto&& langCode : d["targetLanguageIds"]) {
prj.languages.push_back(Language::TryParse(str::to_wstring(langCode)));
auto prj = make_shared<ProjectInfo>();
enum { NO_ID = -1 };

return RefreshToken().then([this, url, prj] () {
return m_api->get(url);
}).then([this, url, prj](json r)
{
// Handle project info
const json& d = r["data"];
prj->name = str::to_wstring(d["name"]);
prj->id = d["id"];
for (const auto& langCode : d["targetLanguageIds"]) {
prj->languages.push_back(Language::TryParse(str::to_wstring(langCode)));
}
//TODO: get more until all files gotten (if more than 500)
return m_api->get(url + "/files?limit=500");
}).then([this, url, prj](json r)
{
// Handle project files
for(auto& i : r["data"]) {
const json& d = i["data"];
if(d["type"] != "assets") {
const json& dir = d["directoryId"],
branch = d["branchId"];
prj->files.push_back({
L"/" + str::to_wstring(d["name"]),
d["id"],
dir.is_null() ? NO_ID : dir.get<int>(),
branch.is_null() ? NO_ID : branch.get<int>()
});
}
return m_api->get(url + "/files?limit=500")
.then([prj_ = prj](json r)
}
//TODO: get more until all dirs gotten (if more than 500)
return m_api->get(url + "/directories?limit=500");
}).then([this, url, prj](json r) {
// Handle directories
struct dir {
string name;
int parentId;
};
map<int, dir> dirs;

for(const auto& i : r["data"]) {
const json& d = i["data"],
parent = d["directoryId"];
dirs.insert({
d["id"],
{
auto prj = prj_;
//TODO: files should be with full path
for(auto&& i : r["data"]) {
const json& d = i["data"];
if(d["type"] != "assets") {
prj.files.push_back({L"/" + str::to_wstring(d["name"]), d["id"]});
}
}
//TODO: get more until all files gotten (if more than 500)
return prj;
});
});
d["name"],
parent.is_null() ? NO_ID : parent.get<int>()
}
});
}

stack<string> path;
for(auto& i : prj->files) {
int dirId = i.dirId;
while(dirId != NO_ID) {
const auto& dir = dirs[dirId];
path.push(dir.name);
dirId = dir.parentId;
}
string pathStr;
while(path.size()) {
pathStr += '/';
pathStr += path.top();
path.pop();
}
if(!pathStr.empty()) {
i.pathName = str::to_wstring(pathStr) + i.pathName;
}
}

//TODO: get more until all branches gotten (if more than 500)
return m_api->get(url + "/branches?limit=500");
}).then([this, url, prj](json r) {
// Handle branches
map<int, string> branches;

for(const auto& i : r["data"]) {
const json& d = i["data"];
branches[d["id"]] = d["name"].get<string>();
}

for(auto& i : prj->files) {
if(i.branchId != NO_ID) {
i.pathName = "/" + str::to_wstring(branches[i.branchId]) + i.pathName;
}
}

return *prj;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/crowdin_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class CrowdinClient
struct FileInfo
{
std::wstring pathName;
int id;
int id, dirId, branchId;

};

Expand Down
2 changes: 1 addition & 1 deletion src/crowdin_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class CrowdinOpenDialog : public wxDialog
localFileName << XLIFFCatalog::GetBaseDir()
<< wxFILE_SEP_PATH << projectId << ' ' << projectName
<< wxFILE_SEP_PATH << lang.Code()
<< wxFILE_SEP_PATH << localName.BeforeLast(wxFILE_SEP_PATH)
<< wxFILE_SEP_PATH << localName.BeforeLast(wxFILE_SEP_PATH) << wxFILE_SEP_PATH
<< fileId << ' ' << localName.AfterLast(wxFILE_SEP_PATH) << ".xliff";
auto localDirName = localFileName.BeforeLast(wxFILE_SEP_PATH);

Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef Poedit_version_h
#define Poedit_version_h

#define POEDIT_VERSION "2.4.8dev"
#define POEDIT_VERSION_WIN 2,4,8
#define POEDIT_VERSION "2.4.10alpha"
#define POEDIT_VERSION_WIN 2,4,10

#endif // Poedit_version_h
2 changes: 1 addition & 1 deletion win32/poedit.iss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "../" + CONFIG + "/git_build_number.h"

#define VERSION "2.4.9"
#define VERSION "2.4.10"
#define VERSION_WIN VERSION + "." + Str(POEDIT_GIT_BUILD_NUMBER)

#ifndef CRT_REDIST
Expand Down

0 comments on commit 6407583

Please sign in to comment.