This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -41,7 +41,7 @@ namespace AyaNova.Biz
|
||||
/// Prime the locales
|
||||
/// This may be called before there are any users on a fresh db boot
|
||||
/// </summary>
|
||||
public static void PrimeLocales()
|
||||
public static async Task PrimeLocales()
|
||||
{//
|
||||
|
||||
|
||||
@@ -53,19 +53,18 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
ImportLocale(ResourceFolderPath, "en");
|
||||
ImportLocale(ResourceFolderPath, "es");
|
||||
ImportLocale(ResourceFolderPath, "fr");
|
||||
ImportLocale(ResourceFolderPath, "de");
|
||||
|
||||
//Ensure locales are present, not missing any keys and that there is a server default locale that exists
|
||||
await ImportLocale(ResourceFolderPath, "en");
|
||||
await ImportLocale(ResourceFolderPath, "es");
|
||||
await ImportLocale(ResourceFolderPath, "fr");
|
||||
await ImportLocale(ResourceFolderPath, "de");
|
||||
|
||||
//Ensure locales are present, not missing any keys and that there is a server default locale that exists
|
||||
LocaleBiz lb = LocaleBiz.GetBizInternal(ServiceProviderProvider.DBContext, 1, AuthorizationRoles.OpsAdminFull);
|
||||
lb.ValidateLocalesAsync();
|
||||
await lb.ValidateLocalesAsync();
|
||||
|
||||
}
|
||||
|
||||
private static void ImportLocale(string resourceFolderPath, string localeCode)
|
||||
private static async Task ImportLocale(string resourceFolderPath, string localeCode)
|
||||
{
|
||||
AyContext ct = ServiceProviderProvider.DBContext;
|
||||
var LocalePath = Path.Combine(resourceFolderPath, $"{localeCode}.json");
|
||||
@@ -74,7 +73,7 @@ namespace AyaNova.Biz
|
||||
throw new System.Exception($"E1013: stock locale file \"{localeCode}\" not found where expected: \"{LocalePath}\", installation damaged?");
|
||||
}
|
||||
|
||||
JObject o = JObject.Parse(File.ReadAllText(LocalePath));
|
||||
JObject o = JObject.Parse(await File.ReadAllTextAsync(LocalePath));
|
||||
|
||||
Locale l = new Locale();
|
||||
l.Name = localeCode;
|
||||
@@ -89,8 +88,8 @@ namespace AyaNova.Biz
|
||||
l.LocaleItems.Add(new LocaleItem() { Key = key, Display = display });//, Locale = l
|
||||
}
|
||||
|
||||
ct.Locale.Add(l);
|
||||
ct.SaveChanges();
|
||||
await ct.Locale.AddAsync(l);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user