This commit is contained in:
2020-04-30 17:54:26 +00:00
parent 37618278b4
commit 8cd6134b13

View File

@@ -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<int> StockLocaleHashes = new List<int>();
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<string> allStrings = new List<string>();
foreach (var entry in lt.LT) {
allStrings.Add(entry.Value);
}
progress.Append("Locale: " + i.Locale + " hash code: " + util.GetOrderIndependentHashCode<string>(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<string> allStrings = new List<string>();
foreach (var entry in lt.LT)
allStrings.Add(entry.Value);
int CurrentLocaleHash = util.GetOrderIndependentHashCode<string>(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