Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Apps.Crowdin/Actions/FileActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public async Task<FileEntity> AddSpreadsheetFile(
}
}

var importOptions = new Apps.Crowdin.Models.Request.File.CustomFileImportOptions
var importOptions = new CustomFileImportOptions
{
FirstLineContainsHeader = input.FirstLineContainsHeader,
ImportTranslations = input.ImportTranslations,
Expand Down
2 changes: 1 addition & 1 deletion Apps.Crowdin/Actions/SourceStringAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task<SourceStringEntity> AddString([ActionParameter] AddSourceStrin
Context = input.Context,
IsHidden = input.IsHidden,
MaxLength = input.MaxLength,
LabelIds = input.LabelIds?.Select(labelId => IntParser.Parse(labelId, nameof(labelId))!.Value).ToList()
LabelIds = input.LabelIds?.Select(labelId => LongParser.Parse(labelId, nameof(labelId))!.Value).ToList()
};
var response = await ExceptionWrapper.ExecuteWithErrorHandling(async () => await SdkClient.SourceStrings
.AddString(intProjectId!.Value, request));
Expand Down
4 changes: 2 additions & 2 deletions Apps.Crowdin/Actions/TaskActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public async Task<TaskEntity> AddTask(
LanguageId = input.LanguageId,
FileIds = input.FileIds.Select(fileId =>
{
if (!int.TryParse(fileId, out var parsedFileId))
if (!long.TryParse(fileId, out var parsedFileId))
throw new PluginMisconfigurationException($"Invalid File ID: {fileId} must be a numeric value. Please check the input file ID");
return parsedFileId;
}).ToList(),
Expand All @@ -144,7 +144,7 @@ public async Task<TaskEntity> AddTask(
SkipUntranslatedStrings = input.SkipUntranslatedStrings,
LabelIds = input.LabelIds?.Select(labelId =>
{
if (!int.TryParse(labelId, out var parsedLabelId))
if (!long.TryParse(labelId, out var parsedLabelId))
throw new PluginMisconfigurationException($"Invalid Label ID: {labelId} must be a numeric value. Please check the input label ID");
return parsedLabelId;
}).ToList(),
Expand Down
31 changes: 9 additions & 22 deletions Apps.Crowdin/Actions/TranslationActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<PreTranslationEntity> PreTranslate(
var request = new ApplyPreTranslationRequest
{
LanguageIds = input.LanguageIds.ToList(),
FileIds = input.FileIds.Select(fileId => IntParser.Parse(fileId, nameof(fileId))!.Value).ToList(),
FileIds = input.FileIds.Select(fileId => LongParser.Parse(fileId, nameof(fileId))!.Value).ToList(),
EngineId = intEngineId,
Method = method,
AiPromptId = input.aiPromptId is null ? null : IntParser.Parse(input.aiPromptId, nameof(input.aiPromptId)),
Expand Down Expand Up @@ -176,20 +176,10 @@ public async Task<TranslationEntity> AddStringTranslation([ActionParameter] AddN
[Action("Add file translation", Description = "Add new file translation")]
public async Task<FileTranslationEntity> AddFileTranslation([ActionParameter] AddNewFileTranslationRequest input)
{
if (string.IsNullOrEmpty(input.LanguageId))
{
throw new PluginMisconfigurationException(
"Language ID cannot be null or empty. Please provide a valid language ID.");
}

if (string.IsNullOrEmpty(input.ProjectId))
{
throw new PluginMisconfigurationException(
"Project ID cannot be null or empty. Please provide a valid project ID.");
}
input.Validate();

int? fileID;
if (!String.IsNullOrEmpty(input.SourceFileId))
if (!string.IsNullOrEmpty(input.SourceFileId))
{
try
{
Expand Down Expand Up @@ -223,18 +213,19 @@ public async Task<FileTranslationEntity> AddFileTranslation([ActionParameter] Ad
await client.Storage.AddStorage(memoryStream, input.File.Name));


var request = new UploadTranslationsRequest
var request = new ImportTranslationsRequest
{
StorageId = storageResult.Id,
FileId = fileID,
ImportEqSuggestions = input.ImportEqSuggestions,
AutoApproveImported = input.AutoApproveImported,
TranslateHidden = input.TranslateHidden
TranslateHidden = input.TranslateHidden,
LanguageIds = [input.LanguageId]
};

var response = await ExceptionWrapper.ExecuteWithErrorHandling(async () =>
await client.Translations.UploadTranslations(intProjectId!.Value, input.LanguageId, request));
return new(response);
await client.Translations.ImportTranslations(intProjectId!.Value, request));

return new(response, intProjectId.ToString());
}

[Action("Delete translation", Description = "Delete specific translation")]
Expand Down Expand Up @@ -280,8 +271,6 @@ await client.Translations.BuildProjectFileTranslation(intProjectId!.Value, intFi
return new(file);
}



[Action("Get language progress", Description = "Get translation progress for a specific language in the project")]
public async Task<SimplifiedLanguageProgressResponseDto> GetLanguageProgress(
[ActionParameter] ProjectRequest project,
Expand Down Expand Up @@ -319,8 +308,6 @@ public async Task<SimplifiedLanguageProgressResponseDto> GetLanguageProgress(
return new SimplifiedLanguageProgressResponseDto { Data = simplifiedList };
}



[Action("Export project translation", Description = "Generate a download link for a project's translation in a specified language for the given files")]
public async Task<ExportProjectTranslationResponse> ExportProjectTranslation(
[ActionParameter] ProjectRequest project,
Expand Down
1 change: 1 addition & 0 deletions Apps.Crowdin/Actions/VendorActions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Apps.Crowdin.Invocables;
using Apps.Crowdin.Models.Entities;
using Apps.Crowdin.Models.Request.Vendors;
using Apps.Crowdin.Models.Response.Vendors;
using Apps.Crowdin.Utils;
Expand Down
4 changes: 2 additions & 2 deletions Apps.Crowdin/Apps.Crowdin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<Nullable>enable</Nullable>
<Product>Crowdin</Product>
<Description>Cloud-based solution that streamlines localization management</Description>
<Version>1.2.39</Version>
<Version>1.2.40</Version>
<AssemblyName>Apps.Crowdin</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blackbird.Applications.Sdk.Common" Version="2.14.0" />
<PackageReference Include="Blackbird.Applications.SDK.Extensions.FileManagement" Version="1.0.1" />
<PackageReference Include="Blackbird.Applications.Sdk.Glossaries.Utils" Version="1.0.2-alpha1" />
<PackageReference Include="Blackbird.Applications.Sdk.Utils" Version="1.1.0-rc.8709" />
<PackageReference Include="Crowdin.Api" Version="2.33.0" />
<PackageReference Include="Crowdin.Api" Version="2.42.0" />
<PackageReference Include="EPPlus" Version="7.7.0" />
<PackageReference Include="MimeTypes" Version="2.5.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
18 changes: 5 additions & 13 deletions Apps.Crowdin/Models/Entities/FileTranslationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@

namespace Apps.Crowdin.Models.Entities;

public class FileTranslationEntity
public class FileTranslationEntity(TranslationImportResponse fileTranslation, string? projectId)
{
[Display("File ID")]
public string FileId { get; set; }
public string FileId { get; set; } = fileTranslation.Attributes.FileId.ToString();

[Display("Language ID")]
public string LanguageId { get; set; }
public string LanguageId { get; set; } = fileTranslation.Attributes.LanguageIds.First().ToString();

[Display("Project ID")]
public string ProjectId { get; set; }
public string? ProjectId { get; set; } = projectId;

[Display("Storage ID")]
public string StorageId { get; set; }

public FileTranslationEntity(UploadTranslationsResponse fileTranslation)
{
FileId = fileTranslation.FileId.ToString();
LanguageId = fileTranslation.LanguageId.ToString();
ProjectId = fileTranslation.ProjectId.ToString();
StorageId = fileTranslation.StorageId.ToString();
}
public string StorageId { get; set; } = fileTranslation.Attributes.StorageId.ToString();
}
20 changes: 7 additions & 13 deletions Apps.Crowdin/Models/Entities/VendorEntity.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
using Crowdin.Api.Vendors;
using Blackbird.Applications.Sdk.Common;

public class VendorEntity
namespace Apps.Crowdin.Models.Entities;

public class VendorEntity(Vendor vendor)
{
[Display("Vendor ID")]
public int Id { get; set; }
public long Id { get; set; } = vendor.Id;

[Display("Name")]
public string Name { get; set; }
public string Name { get; set; } = vendor.Name;

[Display("Description")]
public string? Description { get; set; }
public string? Description { get; set; } = string.IsNullOrWhiteSpace(vendor.Description) ? null : vendor.Description;

[Display("Status")]
public string Status { get; set; }

public VendorEntity(Vendor vendor)
{
Id = vendor.Id;
Name = vendor.Name;
Description = string.IsNullOrWhiteSpace(vendor.Description) ? null : vendor.Description;
Status = vendor.Status.ToString();
}
public string Status { get; set; } = vendor.Status.ToString();
}
2 changes: 1 addition & 1 deletion Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public class AddNewFileRequest : ManageFileRequest
public IEnumerable<string>? ExcludedTargetLanguages { get; set; }

[Display("Attach label IDs")]
public IEnumerable<int>? AttachLabelIds { get; set; }
public IEnumerable<long>? AttachLabelIds { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Apps.Crowdin.DataSourceHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dynamic;
Expand Down Expand Up @@ -31,7 +26,7 @@ public class AddNewSpreadsheetFileRequest : ManageFileRequest
public IEnumerable<string>? ExcludedTargetLanguages { get; set; }

[Display("Attach label IDs")]
public IEnumerable<int>? AttachLabelIds { get; set; }
public IEnumerable<long>? AttachLabelIds { get; set; }

[Display("Content segmentation")]
[Description("If enabled, Crowdin will split content into segments")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using Apps.Crowdin.DataSourceHandlers;
using Apps.Crowdin.Models.Request.Project;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Common.Exceptions;
using Blackbird.Applications.Sdk.Common.Files;

namespace Apps.Crowdin.Models.Request.Translation;

public class AddNewFileTranslationRequest : ProjectRequest
{
[Display("Language ID")]
[DataSource(typeof(LanguagesDataHandler))]
public string LanguageId { get; set; }
[Display("Language ID"), DataSource(typeof(LanguagesDataHandler))]
public string LanguageId { get; set; } = string.Empty;

[Display("File")]
public FileReference File { get; set; }
public FileReference File { get; set; } = null!;

[Display("Source file ID")]
public string? SourceFileId { get; set; }
Expand All @@ -26,4 +26,21 @@ public class AddNewFileTranslationRequest : ProjectRequest

[Display("Translate hidden")]
public bool? TranslateHidden { get; set; }

public AddNewFileTranslationRequest Validate()
{
if (string.IsNullOrEmpty(LanguageId))
{
throw new PluginMisconfigurationException(
"Language ID cannot be null or empty. Please provide a valid language ID.");
}

if (string.IsNullOrEmpty(ProjectId))
{
throw new PluginMisconfigurationException(
"Project ID cannot be null or empty. Please provide a valid project ID.");
}

return this;
}
}
3 changes: 2 additions & 1 deletion Apps.Crowdin/Models/Response/Vendors/GetVendorResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blackbird.Applications.Sdk.Common;
using Apps.Crowdin.Models.Entities;
using Blackbird.Applications.Sdk.Common;

namespace Apps.Crowdin.Models.Response.Vendors;

Expand Down
4 changes: 3 additions & 1 deletion Apps.Crowdin/Models/Response/Vendors/ListVendorsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
namespace Apps.Crowdin.Models.Response.Vendors;
using Apps.Crowdin.Models.Entities;

namespace Apps.Crowdin.Models.Response.Vendors;

public record ListVendorsResponse(VendorEntity[] Vendors);
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public class Attributes
public string Method { get; set; } = default!;

[Display("File IDs")]
public List<int> FileIds { get; set; } = default!;
public List<long> FileIds { get; set; } = default!;

[Display("Label IDs")]
public List<int> LabelIds { get; set; } = default!;
public List<long> LabelIds { get; set; } = default!;

[Display("Language IDs")]
public List<string> LanguageIds { get; set; } = default!;
Expand Down