Esempio n. 1
0
void CrowdinClient::DownloadFile(const std::string& project_id, const std::wstring& file, const Language& lang,
                                 const std::wstring& output_file,
                                 std::function<void()> onSuccess,
                                 error_func_t onError)
{
    // NB: "export_translated_only" means the translation is not filled with the source string
    //     if there's no translation, i.e. what Poedit wants.
    auto url = "/api/project/" + project_id + "/export-file"
                   "?json="
                   "&export_translated_only=1"
                   "&language=" + lang.LanguageTag() +
                   "&file=" + http_client::url_encode(file);
    m_api->download(url, output_file, onSuccess, onError);
}
Esempio n. 2
0
void CrowdinClient::UploadFile(const std::string& project_id, const std::wstring& file, const Language& lang,
                                 const std::string& file_content,
                                 std::function<void()> onSuccess,
                                 error_func_t onError)
{
    auto url = "/api/project/" + project_id + "/upload-translation";

    multipart_form_data data;
    data.add_value("json", "");
    data.add_value("language", lang.LanguageTag());
    data.add_value("import_duplicates", "0");
    data.add_value("import_eq_suggestions", "0");
    data.add_file("files[" + str::to_utf8(file) + "]", "upload.po", file_content);

    m_api->post(url, data, onSuccess, onError);
}