This commit is contained in:
2020-04-30 20:19:43 +00:00
parent d52604982c
commit 9477070010

View File

@@ -500,7 +500,7 @@ namespace AyaNova.PlugIn.V8
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 };
a = await util.PostAsync("Translation/Duplicate",JObject.FromObject(t).ToString());
a = await util.PostAsync("Translation/Duplicate", JObject.FromObject(t).ToString());
var targetTranslationId = util.IdFromResponse(a);
var ctoken = util.CTokenFromResponse(a);
//Ok, have our target locale created, not we need to insert our custom translations one by one
@@ -511,24 +511,19 @@ namespace AyaNova.PlugIn.V8
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;
}
}
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."); }
v8TransItem.Display = v7item.Value;
JObject d = JObject.FromObject(v8TransItem);
progress.SubOp("Posting key: " + v7item.Key);
//update it
await util.PutAsync("Translation/UpdateTranslationItemDisplayText", d.ToString());
await util.PutAsync("Translation/UpdateTranslationItemDisplayText",
JObject.FromObject(new UpdateTranslationItem
{
Id = v8TransItem.Id,
ConcurrencyToken = v8TransItem.ConcurrencyToken,
NewText = v7item.Value
}
).ToString());
}
}
@@ -549,6 +544,12 @@ namespace AyaNova.PlugIn.V8
public long TranslationId { get; set; }
}
public class UpdateTranslationItem
{
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
public string NewText { get; set; }
}
/// <summary>
/// Used by import, translate the old v7 translation key name into the new shorter version