This commit is contained in:
@@ -626,19 +626,18 @@ namespace AyaNova.PlugIn.V8
|
|||||||
Addv7v8IdMap(c.ID, RavenId);
|
Addv7v8IdMap(c.ID, RavenId);
|
||||||
|
|
||||||
//USER OPTIONS
|
//USER OPTIONS
|
||||||
// if (c.ScheduleBackColor != 0 || !string.IsNullOrWhiteSpace(c.EmailAddress))
|
|
||||||
// {
|
|
||||||
var rOptions = await util.GetAsync("user-option/" + RavenId.ToString());
|
|
||||||
d = rOptions.ObjectResponse["data"];
|
|
||||||
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
|
||||||
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
|
|
||||||
if (LocaleMap.ContainsKey(c.DefaultLanguage))
|
|
||||||
d.translationId = LocaleMap[c.DefaultLanguage];
|
|
||||||
else
|
|
||||||
d.translationId = 1;
|
|
||||||
|
|
||||||
await util.PutAsync("user-option/" + RavenId.ToString(), d.ToString());
|
var rOptions = await util.GetAsync("user-option/" + RavenId.ToString());
|
||||||
// }
|
d = rOptions.ObjectResponse["data"];
|
||||||
|
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
||||||
|
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
|
||||||
|
if (LocaleMap.ContainsKey(c.DefaultLanguage))
|
||||||
|
d.translationId = LocaleMap[c.DefaultLanguage];
|
||||||
|
else
|
||||||
|
d.translationId = 1;
|
||||||
|
|
||||||
|
await util.PutAsync("user-option/" + RavenId.ToString(), d.ToString());
|
||||||
|
|
||||||
|
|
||||||
//Attachments / FILES
|
//Attachments / FILES
|
||||||
await ExportAttachments(ObjectTID, progress);
|
await ExportAttachments(ObjectTID, progress);
|
||||||
@@ -805,19 +804,18 @@ namespace AyaNova.PlugIn.V8
|
|||||||
Addv7v8IdMap(c.ID, RavenId);
|
Addv7v8IdMap(c.ID, RavenId);
|
||||||
|
|
||||||
//USER OPTIONS
|
//USER OPTIONS
|
||||||
//if (c.ScheduleBackColor != 0 || !string.IsNullOrWhiteSpace(c.EmailAddress))
|
|
||||||
//{
|
|
||||||
var rOptions = await util.GetAsync("user-option/" + RavenId.ToString());
|
|
||||||
d = rOptions.ObjectResponse["data"];
|
|
||||||
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
|
||||||
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
|
|
||||||
if (LocaleMap.ContainsKey(c.DefaultLanguage))
|
|
||||||
d.translationId = LocaleMap[c.DefaultLanguage];
|
|
||||||
else
|
|
||||||
d.translationId = 1;
|
|
||||||
|
|
||||||
await util.PutAsync("user-option/" + RavenId.ToString(), d.ToString());
|
var rOptions = await util.GetAsync("user-option/" + RavenId.ToString());
|
||||||
// }
|
d = rOptions.ObjectResponse["data"];
|
||||||
|
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
||||||
|
d.emailAddress = string.IsNullOrWhiteSpace(c.EmailAddress) ? null : c.EmailAddress;
|
||||||
|
if (LocaleMap.ContainsKey(c.DefaultLanguage))
|
||||||
|
d.translationId = LocaleMap[c.DefaultLanguage];
|
||||||
|
else
|
||||||
|
d.translationId = 1;
|
||||||
|
|
||||||
|
await util.PutAsync("user-option/" + RavenId.ToString(), d.ToString());
|
||||||
|
|
||||||
|
|
||||||
//Attachments / FILES
|
//Attachments / FILES
|
||||||
await ExportAttachments(ObjectTID, progress);
|
await ExportAttachments(ObjectTID, progress);
|
||||||
@@ -3084,65 +3082,22 @@ namespace AyaNova.PlugIn.V8
|
|||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
progress.Append("Exporting customized Locales");
|
progress.Append("Exporting customized Locales");
|
||||||
|
|
||||||
|
|
||||||
//Get a list of RAVEN translations and ID's
|
|
||||||
var a = await util.GetAsync("translation/list");
|
|
||||||
JArray ja = (JArray)a.ObjectResponse["data"];
|
|
||||||
var RavenLanguageList = ja.ToObject<List<util.NameIdItem>>();//all v8 languages
|
|
||||||
|
|
||||||
|
|
||||||
LocaleList v7LocaleList = LocaleList.GetList();//all v7 languages
|
LocaleList v7LocaleList = LocaleList.GetList();//all v7 languages
|
||||||
foreach (LocaleList.LocaleListInfo i in v7LocaleList)
|
foreach (LocaleList.LocaleListInfo i in v7LocaleList)
|
||||||
{
|
{
|
||||||
ResetUniqueNames();
|
ResetUniqueNames();
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
|
|
||||||
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
|
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
|
||||||
progress.Op("Checking if locale " + i.Locale + " is customized");
|
progress.Op("Checking if locale " + i.Locale + " is customized");
|
||||||
//#if(DEBUG)
|
|
||||||
// //continue;
|
|
||||||
//#endif
|
|
||||||
if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
|
if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
|
||||||
|
|
||||||
//Guess the source language, this will always return at least "en" if nothing else
|
//Guess the source language, this will always return at least "en" if nothing else
|
||||||
var ProbableSourceLocale = GuessCustomLocaleSourceLanguage(lt);
|
var ProbableSourceLocale = GuessCustomLocaleSourceLanguage(lt);
|
||||||
|
|
||||||
//collection to hold items sent to server
|
//collection to hold items sent to server
|
||||||
List<UpdateTranslationItem> exportItems = new List<UpdateTranslationItem>();
|
List<UpdateTranslationItem> exportItems = new List<UpdateTranslationItem>();
|
||||||
|
//MAKE A DUPLICATE (probable source locale here in v7 that matches Raven is duped in Raven as basis for updating with custom v7 translations)
|
||||||
//Iterate all RAVEN languages
|
//i.e. if we guess german is the v7 source of the customized locale then migrate it to the Raven german translation ensuring the best language for the user
|
||||||
// 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
|
|
||||||
//this is some half baked shit,it's intended for when users are exported later but it only works with stock locales
|
|
||||||
//so..not sure the exact point, maybe should just default all to english and let admin fix them later
|
|
||||||
//as they likely will have to anyway. Harmless though I guess so keeping
|
|
||||||
//switch (RavenLocaleName)
|
|
||||||
//{
|
|
||||||
// case "en":
|
|
||||||
// if (!LocaleMap.ContainsKey("English"))
|
|
||||||
// LocaleMap.Add("English", x);
|
|
||||||
// break;
|
|
||||||
// case "fr":
|
|
||||||
// if (!LocaleMap.ContainsKey("Français"))
|
|
||||||
// LocaleMap.Add("Français", x);
|
|
||||||
// break;
|
|
||||||
// case "de":
|
|
||||||
// if (!LocaleMap.ContainsKey("Deutsch"))
|
|
||||||
// LocaleMap.Add("Deutsch", x);
|
|
||||||
// break;
|
|
||||||
// case "es":
|
|
||||||
// if (!LocaleMap.ContainsKey("Español"))
|
|
||||||
// LocaleMap.Add("Español", x);
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//MAKE A DUPLICATE
|
|
||||||
var exportName = GetUniqueName(i.Locale + " (" + ProbableSourceLocale + ")");
|
var exportName = GetUniqueName(i.Locale + " (" + ProbableSourceLocale + ")");
|
||||||
progress.SubOp("");
|
progress.SubOp("Is custom and closest match to " + ProbableSourceLocale);
|
||||||
progress.Op("Exporting " + i.Locale + " to " + exportName);
|
progress.Op("Exporting " + i.Locale + " to " + exportName);
|
||||||
|
|
||||||
int x = 1;//default english locale raven id
|
int x = 1;//default english locale raven id
|
||||||
@@ -3152,15 +3107,14 @@ namespace AyaNova.PlugIn.V8
|
|||||||
x = 3;
|
x = 3;
|
||||||
break;
|
break;
|
||||||
case "de":
|
case "de":
|
||||||
x=4;
|
x = 4;
|
||||||
break;
|
break;
|
||||||
case "es":
|
case "es":
|
||||||
x = 2;
|
x = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
a = await util.PostAsync("translation/duplicate/" + x.ToString());
|
var a = await util.PostAsync("translation/duplicate/" + x.ToString());
|
||||||
var targetTranslationId = util.IdFromResponse(a);
|
var targetTranslationId = util.IdFromResponse(a);
|
||||||
|
|
||||||
//now set the name
|
//now set the name
|
||||||
dynamic dTransName = new JObject();
|
dynamic dTransName = new JObject();
|
||||||
dTransName.id = a.ObjectResponse["data"]["id"];
|
dTransName.id = a.ObjectResponse["data"]["id"];
|
||||||
@@ -3170,37 +3124,23 @@ namespace AyaNova.PlugIn.V8
|
|||||||
dTransName.cjkIndex = a.ObjectResponse["data"]["cjkIndex"];
|
dTransName.cjkIndex = a.ObjectResponse["data"]["cjkIndex"];
|
||||||
var vtemp = await util.PutAsync("translation", dTransName.ToString());
|
var vtemp = await util.PutAsync("translation", dTransName.ToString());
|
||||||
var ctoken = util.CTokenFromResponse(vtemp);
|
var ctoken = util.CTokenFromResponse(vtemp);
|
||||||
// "id": 5,
|
|
||||||
//"concurrency": 92149,
|
|
||||||
//"name": "en-1",
|
|
||||||
//"stock": false,
|
|
||||||
//"cjkIndex": false,
|
|
||||||
|
|
||||||
//add to maps so can set user to it on export
|
//add to maps so can set user to it on export
|
||||||
//going to default to the English based one because
|
|
||||||
//that's the majority of the users
|
|
||||||
if (!LocaleMap.ContainsKey(i.Locale))
|
if (!LocaleMap.ContainsKey(i.Locale))
|
||||||
LocaleMap.Add(i.Locale, targetTranslationId);
|
LocaleMap.Add(i.Locale, targetTranslationId);
|
||||||
//Ok, have our target locale created, now we need to insert our custom translations one by one
|
//Ok, have our target locale created, now we need to insert our custom translations one by one
|
||||||
var trans = ((JArray)a.ObjectResponse["data"]["translationItems"]).ToObject<List<TranslationItem>>();
|
var trans = ((JArray)a.ObjectResponse["data"]["translationItems"]).ToObject<List<TranslationItem>>();
|
||||||
|
|
||||||
var DuplicateAvoidanceList = new List<string>();
|
var DuplicateAvoidanceList = new List<string>();
|
||||||
|
|
||||||
//SET MATCHING KEYS TO OUR TEXT
|
//SET MATCHING KEYS TO OUR TEXT
|
||||||
//iterate v7 locale items
|
//iterate v7 locale items
|
||||||
foreach (var v7item in lt.LT)
|
foreach (var v7item in lt.LT)
|
||||||
{
|
{
|
||||||
|
|
||||||
progress.SubOp("Processing key: " + v7item.Key);
|
progress.SubOp("Processing key: " + v7item.Key);
|
||||||
|
|
||||||
var v8key = Translatev7TranslationKey(v7item.Key);
|
var v8key = Translatev7TranslationKey(v7item.Key);
|
||||||
if (v8key == "**SKIP**") continue;
|
if (v8key == "**SKIP**") continue;
|
||||||
|
|
||||||
if (!DuplicateAvoidanceList.Contains(v8key)) { DuplicateAvoidanceList.Add(v8key); }
|
if (!DuplicateAvoidanceList.Contains(v8key)) { DuplicateAvoidanceList.Add(v8key); }
|
||||||
else continue;
|
else continue;
|
||||||
|
|
||||||
TranslationItem v8TransItem = trans.FirstOrDefault(m => m.Key == v8key);
|
TranslationItem v8TransItem = trans.FirstOrDefault(m => m.Key == v8key);
|
||||||
|
|
||||||
if (v8TransItem == null)
|
if (v8TransItem == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException("On exporting custom locale " + i.Locale + " source key " + v7item.Key + ", destination key " + v8key + " was not found.");
|
throw new ArgumentOutOfRangeException("On exporting custom locale " + i.Locale + " source key " + v7item.Key + ", destination key " + v8key + " was not found.");
|
||||||
@@ -3214,18 +3154,12 @@ namespace AyaNova.PlugIn.V8
|
|||||||
NewText = v7item.Value
|
NewText = v7item.Value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//update it
|
//update it
|
||||||
progress.SubOp("Posting translation " + exportName + " to server ");
|
progress.SubOp("Posting translation " + exportName + " to server ");
|
||||||
await util.PutAsync("translation/updatetranslationitemsdisplaytext",
|
await util.PutAsync("translation/updatetranslationitemsdisplaytext",
|
||||||
JArray.FromObject(exportItems).ToString());
|
JArray.FromObject(exportItems).ToString());
|
||||||
|
|
||||||
progress.Op("");
|
progress.Op("");
|
||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
|
|
||||||
// }//iterate raven stock languages
|
|
||||||
|
|
||||||
}
|
}
|
||||||
progress.Op("");
|
progress.Op("");
|
||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
|
|||||||
Reference in New Issue
Block a user