Last active
September 30, 2020 15:47
-
-
Save KevinJump/788d27de99bbd7acd6d2537081f033ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Jumoo.TranslationManager.Core.Services; | |
using Umbraco.Core; | |
using Umbraco.Core.Logging; | |
namespace TranslationManager.Events | |
{ | |
/// <summary> | |
/// Exmaple how listen for events on translation jobs. in Translation Manager (v2.x) | |
/// </summary> | |
/// <remarks> | |
/// This example listens for the Received event which is fired when a job is uploaded back into | |
/// translation manager (ready for review) .You could then have custom code to check things like | |
/// language and send emails, etc to people | |
/// </remarks> | |
public class EventSetup : ApplicationEventHandler | |
{ | |
private ProfilingLogger profileLogger; | |
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
profileLogger = applicationContext.ProfilingLogger; // so you can log if you need to. | |
TranslationJobService.Received += TranslationJobService_Received; | |
// | |
// TranslationJobService.Approved += TranslationJobService_Approved; // fired when Approve & Publish has been processed | |
// TranslationJobService.Submitted += TranslationJobService_Submitted; // fired when a job is sent for translation | |
// | |
// You can also intercept before things happen and stop them if you need to. | |
// set e.Cancel to true in the method. | |
// TranslationJobService.Submitting += TranslationJobService_Submitting; | |
} | |
private void TranslationJobService_Received(TranslationEventArgs e) | |
{ | |
profileLogger.Logger.Debug<EventSetup>("Processing Received Job {0}", () => e.Job.Name); | |
// the e.Job value contains the job, where you can get things like source and target languages | |
// and work out if you want to notify people. | |
// | |
// e.g | |
var targetCulture = e.Job.TargetCulture.Name; | |
// you will have to write the custom methods | |
var emailAddresses = CustomGetEmailsForLanguage(targetCulture); | |
CustomSendNotifications(emailAddresses, e.Job.Name); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment