LanguageFactoryNewLanguage Method |
Namespace: AskiaPortalCmn
Create a new language and save it
var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D")); var contextValidation = context.Validate(); if (!contextValidation.Success) { throw contextValidation.Exception; } var language = LanguageFactory.NewLanguage(context); if (language == null) { Console.Error.WriteLine("Could not create a new language"); return; } language.Key = "mn-LG"; language.Name = "My new language"; var saveResult = language.Save(); if (saveResult.Success) { Console.WriteLine("The language `{0}` (Id={1}) was successfully saved", language.Name, language.Id); } else { Console.Error.WriteLine("Unable to save the language"); Console.Error.Write(saveResult.Exception.Message); }