public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { LocalizationService.SavedDictionaryItem += SavedDictionaryItem; LocalizationService.DeletingDictionaryItem += DeletingDictionaryItem; DictionaryCache.Fill(); }
private void SavedDictionaryItem(ILocalizationService sv, SaveEventArgs <IDictionaryItem> args) { foreach (var e in args.SavedEntities) { foreach (var t in e.Translations) { DictionaryCache.AddOrUpdate(e.ItemKey, t.Key, t.Value, t.Language.IsoCode); } } }
private void DeletingDictionaryItem(ILocalizationService sv, DeleteEventArgs <IDictionaryItem> args) { foreach (var e in args.DeletedEntities) { foreach (var t in e.Translations) { DictionaryCache.Remove(e.ItemKey + "-" + t.Language.IsoCode); } var children = sv.GetDictionaryItemDescendants(e.Key); if (children.Any()) { foreach (var c in children) { foreach (var t in c.Translations) { DictionaryCache.Remove(c.ItemKey + "-" + t.Language.IsoCode); } } } } }