Skip to content

Instantly share code, notes, and snippets.

@andreaGhisa
andreaGhisa / communitygist.cs
Created December 4, 2018 07:26
TellMeAction
using System.Diagnostics;
using System.Drawing;
using Sdl.TellMe.ProviderApi;
namespace Sdl.Community.DeepLMTProvider.DeepLTellMe
{
public class DeepLStoreAction : AbstractTellMeAction
{
public DeepLStoreAction()
{
using Sdl.TellMe.ProviderApi;
namespace Sdl.Community.DeepLMTProvider.DeepLTellMe
{
[TellMeProvider]
public class DeepLTellMeProvider : ITellMeProvider
{
public string Name => "DeepL tell me provider";
public AbstractTellMeAction[] ProviderActions => new AbstractTellMeAction[]
private void RemoveTp(FileBasedProject studioProject)
{
var entries = studioProject.GetTranslationProviderConfiguration().Entries;
entries.RemoveAt(0);
if (entries.Count > 0)
{
entries[0].MainTranslationProvider.Enabled = true;
entries[0].PerformUpdate = true;
}
var converter = manager.GetConverterToDefaultBilingual(file.LocalFilePath, file.LocalFilePath, null);
var contentProcessor = new MtComparisonTargetContentProcessor(file.Language.IsoAbbreviation, file.Name, enName);
converter.AddBilingualProcessor(new BilingualContentHandlerAdapter(contentProcessor));
converter.Parse();
var segments = contentProcessor.CustomSegments;
public class MtComparisonTargetContentProcessor : AbstractBilingualContentProcessor
{
private readonly string _targetLanguage;
private readonly string _fileName;
private FileBasedProject CreateStudioProject(List<StudioReportFile> studioReportFiles, FileBasedProject project)
{
var providerConfiguration = project.GetTranslationProviderConfiguration();
var path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test"));
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
else
@andreaGhisa
andreaGhisa / communitygist.cs
Created October 2, 2018 13:01
CreateServerBasedTm
[ApplicationInitializer]
public class Create : IApplicationInitializer
{
public void Execute()
{
var uri = new Uri(@"Add your url");
var translationProviderServer = new TranslationProviderServer(uri, false, "user name", "password");
var serverTm = new ServerBasedTranslationMemory(translationProviderServer)
{
@andreaGhisa
andreaGhisa / communitygist.cs
Created July 27, 2018 11:55
Create project
[ApplicationInitializer]
public class CreateProject : IApplicationInitializer
{
public void Execute()
{
//import Sdl.ProjectAutomation.Core.dll
var projectInfo = new ProjectInfo
{
Name = "Project From Plugin",
SourceLanguage = new Language(CultureInfo.GetCultureInfo("en-US")), //import Sdl.core.globalization.dll
@andreaGhisa
andreaGhisa / communitygist.cs
Last active July 27, 2018 06:16
RemoveNotifications
//remove the notification from list
_notificationGroup.Notifications.Remove(notification);
//check if for that group there are any notification remaining
if (_notificationGroup.Notifications.Count > 0)
{
var addNotificationEvent = new AddStudioGroupNotificationEvent(_notificationGroup);
_eventAggregator.Publish(addNotificationEvent);
}
else
@andreaGhisa
andreaGhisa / communitygist.cs
Last active July 26, 2018 11:53
Norification
//get Studio Event Aggregator
_eventAggregator = SdlTradosStudio.Application.GetService<IStudioEventAggregator>();
//create event group
_notificationGroup = new InSourceNotificationGroup(NotificationGroupId)
{
Title = "InSource Notifications"
};
//create notification
@andreaGhisa
andreaGhisa / communitygist.cs
Created July 26, 2018 11:38
IStudioNotificationCommand
public class InSourceCommand : IStudioNotificationCommand
{
private readonly Action action;
public InSourceCommand(Action action)
{
this.action = action;
}
public event EventHandler CanExecuteChanged;