From 8cd6134b1344dca6ab2542ed2794b361221bf801 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 30 Apr 2020 17:54:26 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 97 ++++++++++++++++---------- 1 file changed, 62 insertions(+), 35 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 3538049..5712fed 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -203,7 +203,9 @@ namespace AyaNova.PlugIn.V8 */ - + if (progress.KeepGoing) + await ExportLocales(progress); + return; //Export in correct order: @@ -240,8 +242,8 @@ namespace AyaNova.PlugIn.V8 //BIZ objects if (progress.KeepGoing) await ExportUsers(progress); - if (progress.KeepGoing) - await ExportLocales(progress); + //if (progress.KeepGoing) + // await ExportLocales(progress); @@ -456,53 +458,78 @@ namespace AyaNova.PlugIn.V8 #region locales private async System.Threading.Tasks.Task ExportLocales(ProgressForm progress) { - + progress.Append("Exporting customized Locales"); //checksum locales //if a recognized checksum then don't import because it means it wasn't modified from stock + /* + Stock fresh trial db (fb) values: + Locale: Custom English hash code: 740187325 + Locale: Deutsch hash code: -257973661 + Locale: English hash code: 740187325 + Locale: Español hash code: -373723947 + Locale: Français hash code: -224208815 + */ + List StockLocaleHashes = new List(); + StockLocaleHashes.Add(-257973661); + StockLocaleHashes.Add(740187325); + StockLocaleHashes.Add(-373723947); + StockLocaleHashes.Add(-224208815); - - LocaleList l = LocaleList.GetList(); - progress.Append("Exporting " + l.Count.ToString() + " Locales"); + LocaleList l = LocaleList.GetList(); foreach (LocaleList.LocaleListInfo i in l) { - - if (!progress.KeepGoing) return; - if (i.Locale != "English") - { - LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); - List allStrings = new List(); - foreach (var entry in lt.LT) { - allStrings.Add(entry.Value); - } - - progress.Append("Locale: " + i.Locale + " hash code: " + util.GetOrderIndependentHashCode(allStrings)); - //todo: all locales except English default need to be dealt with - //above skiplocales is incorrect - - //todo: do the language ones by fetching the equivalent language and then bring over from here (if modified) - //maybe there's a way to tell if the stock locales have been edited and skip them if not? Modified date? - //no, need to checksum them I think + LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale); + progress.Op("Checking if locale " + i.Locale + " is customized"); + //calculate hash + List allStrings = new List(); + foreach (var entry in lt.LT) + allStrings.Add(entry.Value); + int CurrentLocaleHash = util.GetOrderIndependentHashCode(allStrings); + allStrings.Clear(); + if (StockLocaleHashes.Contains(CurrentLocaleHash)) continue; + progress.Op("Locale " + i.Locale + " is customized, exporting"); + // progress.Append("Locale: " + i.Locale + " hash code: " + CurrentLocaleHash.ToString()); - //todo: determine what users are set to for locales and only import those ones!!! + /* + - //todo: somehow identify where a custom list not of our own comes from originally so can start with that list - //i.e. someone may have started with spanish then customized some of it so we need to also start with spanish and customize - //likely if can matchup some parts of it then we would know or at least guess. - //Not sure what but maybe something they can't modify, like an internal error or something? + Dev db values: + Locale: Custom English hash code: -673510828 + Locale: Deutsch hash code: -257973661 + Locale: English hash code: 740187325 + Locale: Español hash code: -373723947 + Locale: Français hash code: -224208815 - //need a key translator so can give old and get new then just update it's value + */ + + //todo: all locales except English default need to be dealt with + //above skiplocales is incorrect + + //todo: do the language ones by fetching the equivalent language and then bring over from here (if modified) + //maybe there's a way to tell if the stock locales have been edited and skip them if not? Modified date? + //no, need to checksum them I think + + //todo: determine what users are set to for locales and only import those ones!!! + + + //todo: somehow identify where a custom list not of our own comes from originally so can start with that list + //i.e. someone may have started with spanish then customized some of it so we need to also start with spanish and customize + //likely if can matchup some parts of it then we would know or at least guess. + //Not sure what but maybe something they can't modify, like an internal error or something? + + //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()); - //dynamic d = new JObject(); - //d.id = 1; - //d.name = i.Locale; - //var a = util.PostAsync("Translation/Duplicate", d.ToString()); - } } } #endregion locales