Created
July 11, 2019 11:16
-
-
Save KevinJump/7ac65cedeb65620c94ce6321df404441 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // Example: Hooking into TranslationManager (v8) Events | |
| // | |
| // Shows you how to register for the Events fired by Translation Manager | |
| // these are the job events, each one gets the job object passed to it | |
| // so you can extract info and workout what you might want to do. | |
| // | |
| // | |
| // Packages (if not in web project) | |
| // install-package UmbracoCms.Core (to get composer/component) | |
| // install-package Jumoo.TranslationManager.Core.Binaries | |
| // | |
| using System; | |
| using Umbraco.Core.Composing; | |
| using Jumoo.TranslationManager.Core.Services; | |
| using Umbraco.Core; | |
| namespace Translation.Notifications | |
| { | |
| // Umbraco 8 - Composer / Component Model runs code when site sarts. | |
| public class NotificationComposer : IUserComposer | |
| { | |
| public void Compose(Composition composition) | |
| { | |
| composition.Components() | |
| .Append<NotificationComponent>(); | |
| } | |
| } | |
| public class NotificationComponent : IComponent | |
| { | |
| public void Initialize() | |
| { | |
| TranslationJobService.Received += TranslationJobService_Received; | |
| // post process events (so fired when a thing has happened | |
| /* | |
| TranslationJobService.Submitted; | |
| TranslationJobService.Approved; | |
| TranslationJobService.Published; | |
| */ | |
| // pre processing events (fired before) | |
| // if you set e.cancel = true you can stop the process | |
| /* | |
| TranslationJobService.Submitting; | |
| TranslationJobService.Approving; | |
| TranslationJobService.Publishing; | |
| */ | |
| } | |
| /// <summary> | |
| /// fired when a job is received, so translated values will be in job | |
| /// Status will be Received | |
| /// </summary> | |
| private void TranslationJobService_Received(TranslationEventArgs e) | |
| { | |
| // e.Job contains the whole job | |
| // source language in e.Job.SourceCulture. | |
| // target language in e.Job.TargetCulture | |
| switch (e.Job.TargetCulture.Name.ToLower()) | |
| { | |
| case "es-es": // spanish (spanish) | |
| // SendSpanishEmailHere... (e.Job) | |
| break; | |
| } | |
| } | |
| // umbraco call | |
| public void Terminate() | |
| { | |
| // called at clean up | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment