Locale -> Translation

This commit is contained in:
2020-03-06 19:36:36 +00:00
parent 884c834b3d
commit a234b3531d
58 changed files with 540 additions and 569 deletions

View File

@@ -150,25 +150,25 @@ namespace AyaNova.Util
await ExecQueryAsync("CREATE TABLE asearchkey (id BIGSERIAL PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null, inname bool not null)");
//create locale text tables
await ExecQueryAsync("CREATE TABLE alocale (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)");
//create translation text tables
await ExecQueryAsync("CREATE TABLE atranslation (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)");
//LOOKAT: I don't think this is doing anything:
//exec("CREATE UNIQUE INDEX alocale_name_idx ON alocale (name)");
//exec("CREATE UNIQUE INDEX atranslation_name_idx ON atranslation (name)");
await ExecQueryAsync("CREATE TABLE alocaleitem (id BIGSERIAL PRIMARY KEY, localeid bigint not null REFERENCES alocale (id), key text not null, display text not null)");
await ExecQueryAsync("CREATE TABLE atranslationitem (id BIGSERIAL PRIMARY KEY, translationid bigint not null REFERENCES atranslation (id), key text not null, display text not null)");
//LOOKAT: this is for what exactly??
// exec("CREATE INDEX alocaleitem_localeid_key_idx ON alocaleitem (localeid,key)");
// exec("CREATE INDEX atranslationitem_translationid_key_idx ON atranslationitem (translationid,key)");
//This seems more appropriate
await ExecQueryAsync("CREATE INDEX alocaleitem_localeid_key_display_idx ON alocaleitem (localeid,key, display)");
await ExecQueryAsync("CREATE INDEX atranslationitem_translationid_key_display_idx ON atranslationitem (translationid,key, display)");
//Load the default LOCALES
await AyaNova.Biz.PrimeData.PrimeLocales();
//Load the default TRANSLATIONS
await AyaNova.Biz.PrimeData.PrimeTranslations();
//Add user table
await ExecQueryAsync("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null unique, " +
"login text not null, password text not null, salt text not null, roles integer not null, localeid bigint not null REFERENCES alocale (id), " +
"login text not null, password text not null, salt text not null, roles integer not null, translationid bigint not null REFERENCES atranslation (id), " +
"dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, customerid bigint, " +
"headofficeid bigint, subvendorid bigint, customfields text, tags varchar(255) ARRAY)");

View File

@@ -195,7 +195,7 @@ namespace AyaNova.Util
string text = reader.ReadToEnd();
var j = JObject.Parse(text);
//Here add v7 import file name as sometimes it's needed later (locales)
//Here add v7 import file name as sometimes it's needed later (Translations)
j.Add("V7_SOURCE_FILE_NAME", JToken.FromObject(importFileName));
jList.Add(j);
}

View File

@@ -508,10 +508,10 @@ namespace AyaNova.Util
//TEST NOT ACTIVE - this is used for a test to see if inactive user can login
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminLimited, UserType.NonSchedulable, false, "TEST_INACTIVE", "TEST_INACTIVE");
//Alternate locale users for each stock locale
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "de", "de", await LocaleBiz.LocaleNameToIdStaticAsync("de"));
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "es", "es", await LocaleBiz.LocaleNameToIdStaticAsync("es"));
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "fr", "fr", await LocaleBiz.LocaleNameToIdStaticAsync("fr"));
//Alternate translation users for each stock translation
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "de", "de", await TranslationBiz.TranslationNameToIdStaticAsync("de"));
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "es", "es", await TranslationBiz.TranslationNameToIdStaticAsync("es"));
await GenSeedUserAsync(log, 1, AuthorizationRoles.All, UserType.Administrator, true, "fr", "fr", await TranslationBiz.TranslationNameToIdStaticAsync("fr"));
}
@@ -548,10 +548,10 @@ namespace AyaNova.Util
public static async Task GenSeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType,
bool active = true, string login = null, string password = null, long localeId = 0)
bool active = true, string login = null, string password = null, long translationId = 0)
{
if (localeId == 0)
localeId = ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID;
if (translationId == 0)
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
//Don't do the following commented out, it's slower
// using (var ct = ServiceProviderProvider.DBContext)
@@ -582,7 +582,7 @@ namespace AyaNova.Util
else
u.Password = u.Login;
u.Roles = roles;
u.LocaleId = localeId;
u.TranslationId = translationId;
u.UserType = userType;
u.EmployeeNumber = "A-" + (454 + SeededUserCount).ToString() + "-Y";
u.Notes = Fake.Lorem.Sentence();//Fake.Lorem.Paragraph(2);

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
#if (DEBUG)
internal static List<string> LocaleKeysRequested { get; set; }
internal static List<string> TranslationKeysRequested { get; set; }
#endif
@@ -31,9 +31,9 @@ namespace AyaNova.Util
internal static string AYANOVA_CONTENT_ROOT_PATH { get; set; } //Note: set in startup.cs, not in program.cs as it requires startup IHostingEnvironment
//LANGUAGE / LOCALE
internal static string AYANOVA_DEFAULT_LANGUAGE { get; set; }
internal static long AYANOVA_DEFAULT_LANGUAGE_ID { get; set; } //internal setting set at boot by LocaleBiz::ValidateLocales
//LANGUAGE / Translation
internal static string AYANOVA_DEFAULT_TRANSLATION { get; set; }
internal static long AYANOVA_DEFAULT_TRANSLATION_ID { get; set; } //internal setting set at boot by TranslationBiz::ValidateTranslations
//API
internal static string AYANOVA_JWT_SECRET { get; set; }
@@ -73,7 +73,7 @@ namespace AyaNova.Util
{
#if (DEBUG)
LocaleKeysRequested = new List<string>();
TranslationKeysRequested = new List<string>();
#endif
bool? bTemp = null;
@@ -81,33 +81,33 @@ namespace AyaNova.Util
#region SERVER BASICS
//LANGUAGE
//LocaleBiz will validate this later at boot pfc and ensure a sane default is set (English)
AYANOVA_DEFAULT_LANGUAGE = config.GetValue<string>("AYANOVA_DEFAULT_LANGUAGE");
AYANOVA_DEFAULT_LANGUAGE = string.IsNullOrWhiteSpace(AYANOVA_DEFAULT_LANGUAGE) ? "en" : AYANOVA_DEFAULT_LANGUAGE;
string lowLocale = AYANOVA_DEFAULT_LANGUAGE.ToLowerInvariant();
switch (lowLocale)
//TranslationBiz will validate this later at boot pfc and ensure a sane default is set (English)
AYANOVA_DEFAULT_TRANSLATION = config.GetValue<string>("AYANOVA_DEFAULT_TRANSLATION");
AYANOVA_DEFAULT_TRANSLATION = string.IsNullOrWhiteSpace(AYANOVA_DEFAULT_TRANSLATION) ? "en" : AYANOVA_DEFAULT_TRANSLATION;
string lowTranslation = AYANOVA_DEFAULT_TRANSLATION.ToLowerInvariant();
switch (lowTranslation)
{
case "en":
case "english":
AYANOVA_DEFAULT_LANGUAGE = "en";
AYANOVA_DEFAULT_TRANSLATION = "en";
break;
case "de":
case "deutsch":
case "german":
AYANOVA_DEFAULT_LANGUAGE = "de";
AYANOVA_DEFAULT_TRANSLATION = "de";
break;
case "es":
case "español":
case "spanish":
AYANOVA_DEFAULT_LANGUAGE = "es";
AYANOVA_DEFAULT_TRANSLATION = "es";
break;
case "fr":
case "français":
case "french":
AYANOVA_DEFAULT_LANGUAGE = "fr";
AYANOVA_DEFAULT_TRANSLATION = "fr";
break;
default:
AYANOVA_DEFAULT_LANGUAGE = "en";
AYANOVA_DEFAULT_TRANSLATION = "en";
break;
}