This commit is contained in:
2020-04-30 20:05:57 +00:00
parent 44bb6aa843
commit 88be0323e4

View File

@@ -493,32 +493,45 @@ namespace AyaNova.PlugIn.V8
//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
{ {
//MAKE A DUPLICATE
//name like this: "My custom (Espanol)" etc one for each target stock language //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 + " (" + RavenLanguageList.Find(m => m.Id == x).Name + ")";
progress.Op("Exporting " + i.Locale + " to " + exportName);
var t = new util.NameIdItem { Name = exportName, Id = x }; var t = new util.NameIdItem { Name = exportName, Id = x };
a = await util.PostAsync("Translation/Duplicate"); a = await util.PostAsync("Translation/Duplicate");
var targetTranslationId = util.IdFromResponse(a); var targetTranslationId = util.IdFromResponse(a);
var ctoken = util.CTokenFromResponse(a); var ctoken = util.CTokenFromResponse(a);
//Ok, have our target locale created, not we need to insert our custom translations one by one //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>>();
//SET MATCHING KEYS TO OUR TEXT
//iterate v7 locale items
foreach (var v7item in lt.LT)
{
var v8key = Translatev7TranslationKey(v7item.Key);
TranslationItem v8TransItem = null;
foreach (TranslationItem ti in trans)
{
if (ti.Key == v8key)
{
v8TransItem = ti;
break;
}
}
if (v8TransItem == null) { throw new ArgumentOutOfRangeException("On exporting custom locale " + i.Locale + " source key " + v7item.Key + ", destination key " + v8key + " was not found."); }
v8TransItem.Display = v7item.Value;
JObject d = JObject.FromObject(v8TransItem);
progress.SubOp("Posting key: " + v7item.Key);
//update it
await util.PostAsync("Translation/UpdateTranslationItemDisplayText", d.ToString());
}
} }
//duplicate then replace
//need a key translator so can give old and get new then just update it's value
//dynamic d = new JObject();
//d.id = 1;
//d.name = i.Locale;
//var a = util.PostAsync("Translation/Duplicate", d.ToString());
} }
progress.Op(""); progress.Op("");
@@ -527,6 +540,15 @@ namespace AyaNova.PlugIn.V8
#region locale utility #region locale utility
public class TranslationItem
{
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
public string Key { get; set; }
public string Display { get; set; }
public long TranslationId { get; set; }
}
/// <summary> /// <summary>
/// Used by import, translate the old v7 translation key name into the new shorter version /// Used by import, translate the old v7 translation key name into the new shorter version