From aacb6221dcd429f79ab1db8421902fd1234c50a5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 30 Apr 2020 23:32:45 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 38 ++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 3066e07..e678537 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -159,7 +159,8 @@ namespace AyaNova.PlugIn.V8 private Dictionary Map = new Dictionary(); private Dictionary TagMap = new Dictionary(); private Dictionary CustomFieldLocaleKeys = new Dictionary();//holds custom field Raven as key and v7 custom text for that field for later export - + private Dictionary LocaleMap = new Dictionary(); + private string ImportTag = "v7-import"; /// @@ -180,6 +181,7 @@ namespace AyaNova.PlugIn.V8 Map.Clear(); TagMap.Clear(); CustomFieldLocaleKeys.Clear(); + LocaleMap.Clear(); //admin user (not exported but is there already) @@ -241,11 +243,13 @@ namespace AyaNova.PlugIn.V8 progress.Op("Exporting objects"); //BIZ objects - if (progress.KeepGoing) - await ExportUsers(progress); if (progress.KeepGoing) await ExportLocales(progress); + if (progress.KeepGoing) + await ExportUsers(progress); + + @@ -424,6 +428,7 @@ namespace AyaNova.PlugIn.V8 d = a.ObjectResponse["data"]; d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)); d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress; + d.translationId = LocaleMap[c.DefaultLanguage]; await util.PutAsync("UserOptions/" + RavenId.ToString(), d.ToString()); } @@ -499,14 +504,37 @@ namespace AyaNova.PlugIn.V8 //Iterate all RAVEN languages for (int x = 1; x < 5; x++)//first four translations are the stock ones { + //get raven name of locale + var RavenLocaleName = RavenLanguageList.Find(m => m.Id == x).Name; + //add stock locale mappings in case users are set to a stock one in v7 + //so can set them later + switch (RavenLocaleName) + { + case "en": + LocaleMap.Add("English", x); + break; + case "fr": + LocaleMap.Add("Français", x); + break; + case "de": + LocaleMap.Add("Deutsch", x); + break; + case "es": + LocaleMap.Add("Español", x); + break; + } + //MAKE A DUPLICATE //name like this: "My custom (Espanol)" etc one for each target stock language - var exportName = i.Locale + " (" + RavenLanguageList.Find(m => m.Id == x).Name + ")"; + + var exportName = i.Locale + " (" + RavenLocaleName + ")"; progress.Op("Exporting " + i.Locale + " to " + exportName); var t = new util.NameIdItem { Name = exportName, Id = x }; a = await util.PostAsync("Translation/Duplicate", JObject.FromObject(t).ToString()); var targetTranslationId = util.IdFromResponse(a); var ctoken = util.CTokenFromResponse(a); + //add to maps so can set user to it on export + LocaleMap.Add(i.Locale, targetTranslationId); //Ok, have our target locale created, not we need to insert our custom translations one by one var trans = ((JArray)a.ObjectResponse["data"]["translationItems"]).ToObject>(); @@ -539,7 +567,7 @@ namespace AyaNova.PlugIn.V8 //update it - progress.SubOp("Posting translation to server "); + progress.SubOp("Posting translation "+ exportName +" to server "); await util.PutAsync("Translation/UpdateTranslationItemsDisplayText", JArray.FromObject(exportItems).ToString());