This commit is contained in:
@@ -281,6 +281,12 @@ namespace AyaNova.PlugIn.V8
|
|||||||
TagMap.Clear();
|
TagMap.Clear();
|
||||||
// BankedObjects.Clear();
|
// BankedObjects.Clear();
|
||||||
LocaleMap.Clear();
|
LocaleMap.Clear();
|
||||||
|
//add default raven language and codes
|
||||||
|
LocaleMap.Add("English", 1);
|
||||||
|
LocaleMap.Add("Español", 2);
|
||||||
|
LocaleMap.Add("Français", 3);
|
||||||
|
LocaleMap.Add("Deutsch", 4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//admin user (not exported but is there already)
|
//admin user (not exported but is there already)
|
||||||
@@ -3082,11 +3088,11 @@ namespace AyaNova.PlugIn.V8
|
|||||||
//Get a list of RAVEN translations and ID's
|
//Get a list of RAVEN translations and ID's
|
||||||
var a = await util.GetAsync("translation/list");
|
var a = await util.GetAsync("translation/list");
|
||||||
JArray ja = (JArray)a.ObjectResponse["data"];
|
JArray ja = (JArray)a.ObjectResponse["data"];
|
||||||
var RavenLanguageList = ja.ToObject<List<util.NameIdItem>>();
|
var RavenLanguageList = ja.ToObject<List<util.NameIdItem>>();//all v8 languages
|
||||||
|
|
||||||
|
|
||||||
LocaleList l = LocaleList.GetList();
|
LocaleList v7LocaleList = LocaleList.GetList();//all v7 languages
|
||||||
foreach (LocaleList.LocaleListInfo i in l)
|
foreach (LocaleList.LocaleListInfo i in v7LocaleList)
|
||||||
{
|
{
|
||||||
ResetUniqueNames();
|
ResetUniqueNames();
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
@@ -3098,113 +3104,127 @@ namespace AyaNova.PlugIn.V8
|
|||||||
//#endif
|
//#endif
|
||||||
if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
|
if (!util.LocaleIsCustomized(i.Locale, lt, progress)) continue;
|
||||||
|
|
||||||
//Guess the source language
|
//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>();
|
||||||
|
|
||||||
//Iterate all RAVEN languages
|
//Iterate all RAVEN languages
|
||||||
for (int x = 1; x < 5; x++)//first four translations are the stock ones
|
// for (int x = 1; x < 5; x++)//first four translations are the stock ones
|
||||||
{
|
//{
|
||||||
//get raven name of locale
|
//get raven name of locale
|
||||||
var RavenLocaleName = RavenLanguageList.Find(m => m.Id == x).Name;
|
// var RavenLocaleName = RavenLanguageList.Find(m => m.Id == x).Name;
|
||||||
//add stock locale mappings in case users are set to a stock one in v7
|
//add stock locale mappings in case users are set to a stock one in v7
|
||||||
//so can set them later
|
//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
|
//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
|
//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
|
//as they likely will have to anyway. Harmless though I guess so keeping
|
||||||
switch (RavenLocaleName)
|
//switch (RavenLocaleName)
|
||||||
{
|
//{
|
||||||
case "en":
|
// case "en":
|
||||||
if (!LocaleMap.ContainsKey("English"))
|
// if (!LocaleMap.ContainsKey("English"))
|
||||||
LocaleMap.Add("English", x);
|
// LocaleMap.Add("English", x);
|
||||||
break;
|
// break;
|
||||||
case "fr":
|
// case "fr":
|
||||||
if (!LocaleMap.ContainsKey("Français"))
|
// if (!LocaleMap.ContainsKey("Français"))
|
||||||
LocaleMap.Add("Français", x);
|
// LocaleMap.Add("Français", x);
|
||||||
break;
|
// break;
|
||||||
case "de":
|
// case "de":
|
||||||
if (!LocaleMap.ContainsKey("Deutsch"))
|
// if (!LocaleMap.ContainsKey("Deutsch"))
|
||||||
LocaleMap.Add("Deutsch", x);
|
// LocaleMap.Add("Deutsch", x);
|
||||||
break;
|
// break;
|
||||||
case "es":
|
// case "es":
|
||||||
if (!LocaleMap.ContainsKey("Español"))
|
// if (!LocaleMap.ContainsKey("Español"))
|
||||||
LocaleMap.Add("Español", x);
|
// LocaleMap.Add("Español", x);
|
||||||
break;
|
// break;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//MAKE A DUPLICATE
|
//MAKE A DUPLICATE
|
||||||
var exportName = GetUniqueName(i.Locale + " (" + RavenLocaleName + ")");
|
var exportName = GetUniqueName(i.Locale + " (" + ProbableSourceLocale + ")");
|
||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
progress.Op("Exporting " + i.Locale + " to " + exportName);
|
progress.Op("Exporting " + i.Locale + " to " + exportName);
|
||||||
a = await util.PostAsync("translation/duplicate/" + x.ToString());
|
|
||||||
var targetTranslationId = util.IdFromResponse(a);
|
|
||||||
|
|
||||||
//now set the name
|
|
||||||
dynamic dTransName = new JObject();
|
|
||||||
dTransName.id = a.ObjectResponse["data"]["id"];
|
|
||||||
dTransName.concurrency = a.ObjectResponse["data"]["concurrency"];
|
|
||||||
dTransName.name = exportName;
|
|
||||||
dTransName.stock = false;
|
|
||||||
dTransName.cjkIndex = a.ObjectResponse["data"]["cjkIndex"];
|
|
||||||
var vtemp = await util.PutAsync("translation", dTransName.ToString());
|
|
||||||
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
|
|
||||||
//going to default to the English based one because
|
|
||||||
//that's the majority of the users
|
|
||||||
if (RavenLocaleName == "en" && !LocaleMap.ContainsKey(i.Locale))
|
|
||||||
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<List<TranslationItem>>();
|
|
||||||
|
|
||||||
var DuplicateAvoidanceList = new List<string>();
|
|
||||||
|
|
||||||
//SET MATCHING KEYS TO OUR TEXT
|
|
||||||
//iterate v7 locale items
|
|
||||||
foreach (var v7item in lt.LT)
|
|
||||||
{
|
|
||||||
|
|
||||||
progress.SubOp("Processing key: " + v7item.Key);
|
|
||||||
|
|
||||||
var v8key = Translatev7TranslationKey(v7item.Key);
|
|
||||||
if (v8key == "**SKIP**") continue;
|
|
||||||
|
|
||||||
if (!DuplicateAvoidanceList.Contains(v8key)) { DuplicateAvoidanceList.Add(v8key); }
|
|
||||||
else continue;
|
|
||||||
|
|
||||||
TranslationItem v8TransItem = trans.FirstOrDefault(m => m.Key == v8key);
|
|
||||||
|
|
||||||
if (v8TransItem == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException("On exporting custom locale " + i.Locale + " source key " + v7item.Key + ", destination key " + v8key + " was not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//collect
|
|
||||||
exportItems.Add(new UpdateTranslationItem
|
|
||||||
{
|
|
||||||
Id = v8TransItem.Id,
|
|
||||||
Concurrency = v8TransItem.Concurrency,
|
|
||||||
NewText = v7item.Value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//update it
|
|
||||||
progress.SubOp("Posting translation " + exportName + " to server ");
|
|
||||||
await util.PutAsync("translation/updatetranslationitemsdisplaytext",
|
|
||||||
JArray.FromObject(exportItems).ToString());
|
|
||||||
|
|
||||||
progress.Op("");
|
|
||||||
progress.SubOp("");
|
|
||||||
|
|
||||||
|
int x = 1;//default english locale raven id
|
||||||
|
switch (ProbableSourceLocale)
|
||||||
|
{
|
||||||
|
case "fr":
|
||||||
|
x = 3;
|
||||||
|
break;
|
||||||
|
case "de":
|
||||||
|
x=4;
|
||||||
|
break;
|
||||||
|
case "es":
|
||||||
|
x = 2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
a = await util.PostAsync("translation/duplicate/" + x.ToString());
|
||||||
|
var targetTranslationId = util.IdFromResponse(a);
|
||||||
|
|
||||||
|
//now set the name
|
||||||
|
dynamic dTransName = new JObject();
|
||||||
|
dTransName.id = a.ObjectResponse["data"]["id"];
|
||||||
|
dTransName.concurrency = a.ObjectResponse["data"]["concurrency"];
|
||||||
|
dTransName.name = exportName;
|
||||||
|
dTransName.stock = false;
|
||||||
|
dTransName.cjkIndex = a.ObjectResponse["data"]["cjkIndex"];
|
||||||
|
var vtemp = await util.PutAsync("translation", dTransName.ToString());
|
||||||
|
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
|
||||||
|
//going to default to the English based one because
|
||||||
|
//that's the majority of the users
|
||||||
|
if (!LocaleMap.ContainsKey(i.Locale))
|
||||||
|
LocaleMap.Add(i.Locale, targetTranslationId);
|
||||||
|
//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 DuplicateAvoidanceList = new List<string>();
|
||||||
|
|
||||||
|
//SET MATCHING KEYS TO OUR TEXT
|
||||||
|
//iterate v7 locale items
|
||||||
|
foreach (var v7item in lt.LT)
|
||||||
|
{
|
||||||
|
|
||||||
|
progress.SubOp("Processing key: " + v7item.Key);
|
||||||
|
|
||||||
|
var v8key = Translatev7TranslationKey(v7item.Key);
|
||||||
|
if (v8key == "**SKIP**") continue;
|
||||||
|
|
||||||
|
if (!DuplicateAvoidanceList.Contains(v8key)) { DuplicateAvoidanceList.Add(v8key); }
|
||||||
|
else continue;
|
||||||
|
|
||||||
|
TranslationItem v8TransItem = trans.FirstOrDefault(m => m.Key == v8key);
|
||||||
|
|
||||||
|
if (v8TransItem == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("On exporting custom locale " + i.Locale + " source key " + v7item.Key + ", destination key " + v8key + " was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//collect
|
||||||
|
exportItems.Add(new UpdateTranslationItem
|
||||||
|
{
|
||||||
|
Id = v8TransItem.Id,
|
||||||
|
Concurrency = v8TransItem.Concurrency,
|
||||||
|
NewText = v7item.Value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//update it
|
||||||
|
progress.SubOp("Posting translation " + exportName + " to server ");
|
||||||
|
await util.PutAsync("translation/updatetranslationitemsdisplaytext",
|
||||||
|
JArray.FromObject(exportItems).ToString());
|
||||||
|
|
||||||
|
progress.Op("");
|
||||||
|
progress.SubOp("");
|
||||||
|
|
||||||
|
// }//iterate raven stock languages
|
||||||
|
|
||||||
}
|
}
|
||||||
progress.Op("");
|
progress.Op("");
|
||||||
@@ -3439,9 +3459,11 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
public string GuessCustomLocaleSourceLanguage(LocalizedTextTable lt)
|
public string GuessCustomLocaleSourceLanguage(LocalizedTextTable lt)
|
||||||
{
|
{
|
||||||
|
//try to match up some likely not edited locale translations
|
||||||
|
//and give weight to the language with the most matches
|
||||||
|
//if no matches should default to en
|
||||||
Dictionary<string, int> d = new Dictionary<string, int>();
|
Dictionary<string, int> d = new Dictionary<string, int>();
|
||||||
d.Add("en", 0);//weight towards english?
|
d.Add("en", 0);//this will default if nothing is matched as sort will just keep same order
|
||||||
d.Add("de", 0);
|
d.Add("de", 0);
|
||||||
d.Add("fr", 0);
|
d.Add("fr", 0);
|
||||||
d.Add("es", 0);
|
d.Add("es", 0);
|
||||||
@@ -3466,7 +3488,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var v = lt.LT["Global.Label.AllowScheduleConflicts"];
|
var v = lt.LT["Global.Label.AllowScheduleConflicts"];
|
||||||
switch (v)
|
switch (v)
|
||||||
{
|
{
|
||||||
@@ -3485,7 +3507,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var v = lt.LT["ReportEditor.Label.Properties"];
|
var v = lt.LT["ReportEditor.Label.Properties"];
|
||||||
switch (v)
|
switch (v)
|
||||||
{
|
{
|
||||||
@@ -3504,7 +3526,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var v = lt.LT["UI.Help.TechSupport"];
|
var v = lt.LT["UI.Help.TechSupport"];
|
||||||
switch (v)
|
switch (v)
|
||||||
{
|
{
|
||||||
@@ -3523,7 +3545,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var v = lt.LT["StopWords3"];
|
var v = lt.LT["StopWords3"];
|
||||||
switch (v)
|
switch (v)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user