public AboutController(IStringLocalizer <SharedResource> localizer, IStringLocalizer <AboutController> aboutLocalizerizer, IStringExtendedLocalizerFactory stringExtendedLocalizerFactory, LocalizationModelContext context) { _localizer = localizer; _aboutLocalizerizer = aboutLocalizerizer; _stringExtendedLocalizerFactory = stringExtendedLocalizerFactory; _context = context; }
public ProductCudProvider(ProductContext productContext, LocalizationModelContext localizationModelContext, IStringExtendedLocalizerFactory stringLocalizerFactory) { _productContext = productContext; _localizationModelContext = localizationModelContext; _stringLocalizerFactory = stringLocalizerFactory; }
public LocalizationRepository(IOptions <SqlContextOptions> sqlContextOption, IStringExtendedLocalizerFactory sqlLocalizerFactory, LocalizationModelContext localizationContext, IJsonManagerRepository jsonManagerRepository) { _SqlContextOption = sqlContextOption; _SqlLocalizerFactory = sqlLocalizerFactory; _LocalizationContext = localizationContext; _JsonManagerRepository = jsonManagerRepository; }
public DataSeeder(LocalizationModelContext ltx, IStringExtendedLocalizerFactory stringExtendedLocalizerFactory) { _ltx = ltx; _stringExtendedLocalizerFactory = stringExtendedLocalizerFactory; location = System.Reflection.Assembly.GetEntryAssembly().Location; directory = System.IO.Path.GetDirectoryName(location); filepath = directory + "\\Data\\"; }
/// <summary> /// Find a Localization Record from Localization DB, with Key, ResourceKey and Culture /// </summary> /// <param name="key">Key of key-value pair in Localization Record</param> /// <param name="resourceKey">The Type of Record, Domain specificity </param> /// <param name="localizationCulture">Translation Language / Current Culture</param> async Task <LocalizationRecord> ILocalizationRepository.GetLocalizationRecord(string key, string resourceKey, string localizationCulture) { var _resource = new LocalizationRecord(); var _sqliteOptions = new DbContextOptionsBuilder <LocalizationModelContext>() .UseSqlite(_SqlContextOption.Value.ConLocalization) .Options; using (var localizationContext = new LocalizationModelContext(_sqliteOptions, _SqlContextOption)) { _resource = await localizationContext.LocalizationRecords.FirstOrDefaultAsync(r => r.Key == key && r.ResourceKey == resourceKey && r.LocalizationCulture == localizationCulture); } return(_resource); }
/// <summary> /// Find Localization Records from Localization DB, with searchKey and Culture /// </summary> /// <param name="searchKey">The term to match in Key/Value of Localization Resources</param> /// <param name="localizationCulture">Translation Language / Current Culture</param> async Task <ICollection <LocalizationRecord> > ILocalizationRepository.SearchLocalizationRecords(string searchKey, string localizationCulture) { var _resources = new List <LocalizationRecord>(); var _sqliteOptions = new DbContextOptionsBuilder <LocalizationModelContext>() .UseSqlite(_SqlContextOption.Value.ConLocalization) .Options; using (var localizationContext = new LocalizationModelContext(_sqliteOptions, _SqlContextOption)) { _resources = await localizationContext.LocalizationRecords.Where(r => r.LocalizationCulture == localizationCulture && (r.Key.ToLower().Contains(searchKey.ToLower()) || r.Text.ToLower().Contains(searchKey.ToLower()))).ToListAsync(); } return(_resources); }
/// <summary> /// Get all the keys from SQLite DB file for server resource culture/translateTo /// </summary> /// <param name="translateTo">translate lang: string </param> async Task <string[]> ILocalizationRepository.GetServerResourceKeys(string translateTo) { string[] resourceKeys = null; var _sqliteOptions = new DbContextOptionsBuilder <LocalizationModelContext>() .UseSqlite(_SqlContextOption.Value.ConLocalization) .Options; using (var localizationContext = new LocalizationModelContext(_sqliteOptions, _SqlContextOption)) { resourceKeys = await localizationContext.LocalizationRecords.Where(r => r.LocalizationCulture.ToLower() == translateTo.ToLower()) .Select(r => r.ResourceKey).Distinct() .ToArrayAsync(); } return(resourceKeys); }
public SqlStringLocalizerFactory( LocalizationModelContext context, IOptions<SqlLocalizationOptions> localizationOptions) { if (context == null) { throw new ArgumentNullException(nameof(LocalizationModelContext)); } if (localizationOptions == null) { throw new ArgumentNullException(nameof(localizationOptions)); } _options = localizationOptions; _context = context; }
/// <summary> /// Update a Localization Record from Localization DB, with Key, ResourceKey and Culture /// </summary> /// <param name="key">Key of key-value pair in Localization Record</param> /// <param name="text">Value of Key-Value pair in Localization Record</param> /// <param name="resourceKey">The Type of Record, Domain specificity </param> /// <param name="localizationCulture">Translation Language / Current Culture</param> async Task <IJsonResult> ILocalizationRepository.UpdateLocalizationRecord(string key, string text, string resourceKey, string localizationCulture, bool addIfNotFound) { IJsonResult jsonResult = new MyJsonResult() { Message = $"Failed to update translation for '{key}' to '{text}'", Result = JsonResultFlag.Failed }; LocalizationRecord _resource = await((ILocalizationRepository)this).GetLocalizationRecord(key, resourceKey, localizationCulture); if (_resource != null) { var _sqliteOptions = new DbContextOptionsBuilder <LocalizationModelContext>() .UseSqlite(_SqlContextOption.Value.ConLocalization) .Options; using (var localizationContext = new LocalizationModelContext(_sqliteOptions, _SqlContextOption)) { _resource.Text = text; var data = new List <LocalizationRecord>(); data.Add(_resource); _SqlLocalizerFactory.UpdateLocalizationData(data, DateTimeOffset.UtcNow.ToString()); // localizationContext.Entry(_resource).State = EntityState.Modified; // await localizationContext.SaveChangesAsync(); jsonResult.Result = JsonResultFlag.Succeeded; jsonResult.Message = $"Successfully updated translation for '{key}' to '{text}'"; } } else { if (addIfNotFound) { jsonResult = await((ILocalizationRepository)this).AddLocalizationRecord(key, text, resourceKey, localizationCulture); } else { jsonResult.Result = JsonResultFlag.NotFound; jsonResult.Message = $"Resource not found to be updated, translation for '{key}' to '{text}'"; } } return(jsonResult); }
public LocalizationDataInitializer(LocalizationModelContext ctx, IStringExtendedLocalizerFactory localizer) { this.context = ctx; this.localizer = localizer; }
//private readonly RazorViewToStringRenderer _razorViewToStringRenderer; public LocalizationController(LocalizationModelContext context, IStringExtendedLocalizerFactory stringExtendedLocalizerFactory /*, RazorViewToStringRenderer razorViewToStringRenderer*/) { _context = context; _stringExtendedLocalizerFactory = stringExtendedLocalizerFactory; //_razorViewToStringRenderer = razorViewToStringRenderer; }
public LocalizationDataInitializer(LocalizationModelContext ctx) { context = ctx; }
public LocalizationInitHosted(LocalizationModelContext localizationModelContext) { _localizationModelContext = localizationModelContext; }
public MySqlStringLocalizerFactory(LocalizationModelContext context, DevelopmentSetup developmentSetup, IOptions <SqlLocalizationOptions> localizationOptions) : base(context, developmentSetup, localizationOptions) { }