This commit is contained in:
2020-04-30 19:47:14 +00:00
parent d35653a851
commit 44bb6aa843
2 changed files with 136 additions and 43 deletions

View File

@@ -469,6 +469,12 @@ namespace AyaNova.PlugIn.V8
StockLocaleHashes.Add(-373723947);
StockLocaleHashes.Add(-224208815);
//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>>();
LocaleList l = LocaleList.GetList();
foreach (LocaleList.LocaleListInfo i in l)
{
@@ -484,48 +490,23 @@ namespace AyaNova.PlugIn.V8
allStrings.Clear();
if (StockLocaleHashes.Contains(CurrentLocaleHash)) continue;
progress.Op("Locale " + i.Locale + " is customized");
progress.SubOp("Determing closest source Locale");
int nEnglishSimilar = 0;
int nFrenchSimilar = 0;
int nSpanishSimilar = 0;
int nGermanSimilar = 0;
LocalizedTextTable ltTemp = LocalizedTextTable.Load("English");
nEnglishSimilar = lt.LT.Where(entry => ltTemp.LT[entry.Key] != entry.Value)
.ToDictionary(entry => entry.Key, entry => entry.Value).Count;
ltTemp = LocalizedTextTable.Load("Français");
nFrenchSimilar = lt.LT.Where(entry => ltTemp.LT[entry.Key] != entry.Value)
.ToDictionary(entry => entry.Key, entry => entry.Value).Count;
ltTemp = LocalizedTextTable.Load("Español");
nSpanishSimilar = lt.LT.Where(entry => ltTemp.LT[entry.Key] != entry.Value)
.ToDictionary(entry => entry.Key, entry => entry.Value).Count;
ltTemp = LocalizedTextTable.Load("Deutsch");
nGermanSimilar = lt.LT.Where(entry => ltTemp.LT[entry.Key] != entry.Value)
.ToDictionary(entry => entry.Key, entry => entry.Value).Count;
string closestSource = "English";
int closestCount = nEnglishSimilar;
if (nFrenchSimilar > closestCount)
//Iterate all RAVEN languages
for(int x=1;x<5;x++)//first four translations are the stock ones
{
closestSource = "Français";
closestCount = nFrenchSimilar;
}
if (nSpanishSimilar > closestCount)
{
closestSource = "Español";
closestCount = nSpanishSimilar;
}
if (nGermanSimilar > closestCount)
{
closestSource = "Deutsch";
closestCount = nGermanSimilar;
}
progress.SubOp("Closest match to base export is " + closestSource);
//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 t = new util.NameIdItem { Name = exportName, Id = x };
a = await util.PostAsync("Translation/Duplicate");
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
//Duplicate closest match RAVEN translation, then update each value that differs from stock
}
//duplicate then replace
@@ -543,6 +524,111 @@ namespace AyaNova.PlugIn.V8
progress.Op("");
progress.SubOp("");
}
#region locale utility
/// <summary>
/// Used by import, translate the old v7 translation key name into the new shorter version
/// </summary>
/// <param name="oldKey"></param>
/// <returns></returns>
public string Translatev7TranslationKey(string oldKey)
{
string s = oldKey.Replace(".Label.", ".");
if (s.StartsWith("O."))
s = s.Replace("O.", "");
s = s.Replace(".ToolBar.", ".");
s = s.Replace(".Go.", ".");
s = s.Replace(".Command.", ".");
s = s.Replace(".Error.", ".");
s = s.Replace(".Object.", ".");
if (s.StartsWith("UI."))
s = s.Replace("UI.", "");
s = s.Replace(".", "");
s = s.Replace("AddressAddress", "Address");
s = s.Replace("ContactPhoneContactPhone", "ContactPhone");
s = s.Replace("ContactPhonePhone", "ContactPhone");
s = s.Replace("PurchaseOrderPurchaseOrder", "PurchaseOrder");
s = s.Replace("WorkorderItemMiscExpenseExpense", "WorkorderItemMiscExpense");
s = s.Replace("WorkorderItemTravelTravel", "WorkorderItemTravel");
s = s.Replace("DashboardDashboard", "Dashboard");
//ScheduleMarkers -> Reminder
s = s.Replace("ScheduleMarker", "Reminder");
s = s.Replace("ScheduleMarkerARGB", "ReminderARGB");
s = s.Replace("ScheduleMarkerColor", "ReminderColor");
s = s.Replace("ScheduleMarkerCompleted", "ReminderCompleted");
s = s.Replace("ScheduleMarkerEventCreated", "ReminderEventCreated");
s = s.Replace("ScheduleMarkerEventPendingAlert", "ReminderEventPendingAlert");
s = s.Replace("ScheduleMarkerFollowUp", "ReminderFollowUp");
s = s.Replace("ScheduleMarkerList", "ReminderList");
s = s.Replace("ScheduleMarkerName", "ReminderName");
s = s.Replace("ScheduleMarkerNotes", "ReminderNotes");
s = s.Replace("ScheduleMarkerRecurrence", "ReminderRecurrence");
s = s.Replace("ScheduleMarkerScheduleMarkerSourceType", "ReminderSourceType");
s = s.Replace("ScheduleMarkerSourceID", "ReminderSourceID");
s = s.Replace("ScheduleMarkerStartDate", "ReminderStartDate");
s = s.Replace("ScheduleMarkerStopDate", "ReminderStopDate");
s = s.Replace("ScheduleEditScheduleMarker", "ScheduleEditReminder");
s = s.Replace("ScheduleNewScheduleMarker", "ScheduleNewReminder");
//Custom fields were 0 to 9, now 1 to 16
s = s.Replace("Custom9", "Custom10");
s = s.Replace("Custom8", "Custom9");
s = s.Replace("Custom7", "Custom8");
s = s.Replace("Custom6", "Custom7");
s = s.Replace("Custom5", "Custom6");
s = s.Replace("Custom4", "Custom5");
s = s.Replace("Custom3", "Custom4");
s = s.Replace("Custom2", "Custom3");
if (!s.EndsWith("Custom10"))
s = s.Replace("Custom1", "Custom2");
s = s.Replace("Custom0", "Custom1");
//separate code will handle adding the new keys that didn't exist in v7 (custom 11 - 16)
//CommonActive CommonID etc remove Common
s = s.Replace("Common", "");
//Misc
s = s.Replace("FormFieldDataType", "UiFieldDataType");
s = s.Replace("UserUserType", "UserType");
s = s.Replace("UserTypesUtilityNotification", "UserTypesUtility");
//Localized -> Translation
s = s.Replace("LocaleCustomizeText", "TranslationCustomizeText");
s = s.Replace("LocaleExport", "TranslationExport");
s = s.Replace("LocaleImport", "TranslationImport");
s = s.Replace("LocaleList", "TranslationList");
s = s.Replace("LocaleLocaleFile", "TranslationFile");
s = s.Replace("LocaleUIDestLocale", "TranslationDest");
s = s.Replace("LocaleUISourceLocale", "TranslationSource");
s = s.Replace("LocaleWarnLocaleLocked", "TranslationWarnLocked");
s = s.Replace("LocalizedTextDisplayText", "TranslationDisplayText");
s = s.Replace("LocalizedTextDisplayTextCustom", "TranslationDisplayTextCustom");
s = s.Replace("LocalizedTextKey", "TranslationKey");
s = s.Replace("LocalizedTextLocale", "Translation");
s = s.Replace("LocalizedText", "TranslatedText");
//FUTURE
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
// s = s.Replace("WASXXX", "NOWXXXX");
return s;
}
#endregion locale utility
#endregion locales
#region TAG ITEMS
@@ -836,8 +922,7 @@ namespace AyaNova.PlugIn.V8
}
#endregion attachments
#region WIKI page exporter
@@ -1358,8 +1443,7 @@ and this one
#endregion sample
#endregion wiki
#region TAGS
private void Tagit(Guid g, List<string> tags)
{
@@ -1383,6 +1467,8 @@ and this one
#endregion tags
#region OLD JSON EXPORT STUFF
#region Global settings
private void ExportGlobalSettings(ProgressForm progress)

View File

@@ -377,6 +377,13 @@ namespace AyaNova.PlugIn.V8
}
return hash;
}
public class NameIdItem
{
public long Id { get; set; }
public string Name { get; set; }
}
#endregion
}//eoc