/// <summary> /// Get all prompts that have been created for an language /// </summary> /// <param name="culture">Culture to get translation for</param> /// <param name="templateCulture">Culture to find not translated prompts in (or same culture to disable)</param> /// <param name="filter">Used to limit the search result</param> /// <returns> /// A collection of prompts /// </returns> public IEnumerable<ViewPrompt> GetAllPrompts(CultureInfo culture, CultureInfo templateCulture, SearchFilter filter) { if (culture == null) throw new ArgumentNullException("culture"); var sql = "SELECT LocaleId, [Key], ViewPath, TextName, Value, UpdatedAt, UpdatedBy FROM LocalizedViews WHERE LocaleId = @LocaleId"; using (var cmd = _db.Connection.CreateCommand()) { cmd.CommandText = sql; cmd.AddParameter("LocaleId", culture.LCID); if (!string.IsNullOrEmpty(filter.TextFilter)) { cmd.CommandText += " AND (TextName LIKE @TextFilter OR Value LIKE @TextFilter)"; cmd.AddParameter("TextFilter", '%' + filter.TextFilter + "%"); } if (!string.IsNullOrEmpty(filter.Path)) { cmd.CommandText += " AND ViewPath LIKE @viewPath"; cmd.AddParameter("viewPath", filter.Path + "%"); } if (filter.OnlyNotTranslated) { cmd.CommandText += " AND (Value is null OR Value LIKE '')"; } return MapCollection(cmd); } }
/// <summary> /// Get all prompts /// </summary> /// <param name="cultureInfo"> Culture to get prompts for </param> /// <param name="defaultCulture"> Culture used as template to be able to include all non-translated prompts </param> /// <param name="filter"> The filter. </param> /// <returns> Collection of translations </returns> public IEnumerable<TypePrompt> GetPrompts(CultureInfo cultureInfo, CultureInfo defaultCulture, SearchFilter filter) { var sql = "SELECT * FROM LocalizedTypes WHERE LocaleId = @LocaleId"; using (var cmd = _db.Connection.CreateCommand()) { cmd.CommandText = sql; cmd.AddParameter("LocaleId", cultureInfo.LCID); if (!string.IsNullOrEmpty(filter.TextFilter)) { cmd.CommandText += " AND (TypeName LIKE @TextFilter OR TextName LIKE @TextFilter)"; cmd.AddParameter("TextFilter", '%' + filter.TextFilter + "%"); } if (!string.IsNullOrEmpty(filter.Path)) { cmd.CommandText += " AND TypeName LIKE @PartialName"; cmd.AddParameter("PartialName", filter.Path + "%"); } if (filter.OnlyNotTranslated) { cmd.CommandText += " AND (Value IS null OR Value LIKE '')"; } using (var reader = cmd.ExecuteReader()) { var items = new List<TypePrompt>(); while (reader.Read()) { items.Add(MapEntity(reader)); } return items; } } }
/// <summary> /// Get all prompts that have been created for an language /// </summary> /// <param name="culture">Culture to get translation for</param> /// <param name="templateCulture">Culture to find not translated prompts in (or same culture to disable)</param> /// <param name="filter">Used to limit the search result</param> /// <returns> /// A collection of prompts /// </returns> public IEnumerable<ViewPrompt> GetAllPrompts(CultureInfo culture, CultureInfo templateCulture, SearchFilter filter) { if (culture == null) throw new ArgumentNullException("culture"); var sql = "SELECT LocaleId, [Key], ViewPath, TextName, Value, UpdatedAt, UpdatedBy FROM LocalizedViews WHERE LocaleId = @LocaleId"; using (var cmd = _db.Connection.CreateCommand()) { cmd.CommandText = sql; cmd.AddParameter("LocaleId", culture.LCID); return MapCollection(cmd); } }
public IEnumerable<ViewPrompt> GetAllPrompts(CultureInfo cultureInfo, CultureInfo templateCulture, SearchFilter filter) { var query = _Set.Where(lt => lt.LocaleId == cultureInfo.LCID); if (!string.IsNullOrEmpty(filter.TextFilter)) query = query.Where(lt => lt.Value.Contains(filter.TextFilter) || lt.TextName.Contains(filter.TextFilter)); if (!string.IsNullOrEmpty(filter.Path)) query = query.Where(lt => lt.ViewPath.Contains(filter.Path)); if (filter.OnlyNotTranslated) query = query.Where(lt => lt.Value == null || lt.Value == ""); var result = query.ToList().Select(lt => lt.ToViewPrompt()); return result; }
/// <summary> /// Get all prompts /// </summary> /// <param name="cultureInfo">Culture to get prompts for</param> /// <param name="defaultCulture">Culture used as template to be able to include all non-translated prompts</param> /// <param name="filter">The filter.</param> /// <returns> /// Collection of translations /// </returns> public IEnumerable<TypePrompt> GetPrompts(CultureInfo cultureInfo, CultureInfo defaultCulture, SearchFilter filter) { var sql = "SELECT * FROM LocalizedTypes WHERE LocaleId = @LocaleId"; using (var cmd = _db.Connection.CreateCommand()) { cmd.CommandText = sql; cmd.AddParameter("LocaleId", cultureInfo.LCID); using (var reader = cmd.ExecuteReader()) { var items = new List<TypePrompt>(); while (reader.Read()) { items.Add(MapEntity(reader)); } return items; } } }
public ActionResult Index(FilterModel filter = null) { if (Request.HttpMethod == "POST" && filter != null) { TableFilter = filter.TableFilter; OnlyNotTranslated = filter.OnlyNotTranslated; } var sf = new SearchFilter(); if (TableFilter != null) sf.Path = TableFilter; if (OnlyNotTranslated) sf.OnlyNotTranslated = true; var model = new IndexModel { Cultures = _repository.GetAvailableLanguages(), Prompts = _repository.GetAllPrompts(CultureInfo.CurrentUICulture, DefaultUICulture.Value, sf).Select(p => new ViewPrompt(p)), OnlyNotTranslated = OnlyNotTranslated, TableFilter = TableFilter }; return View(model); }
private List<Localization.Views.ViewPrompt> GetPromptsForExport(string filter, bool includeCommon, bool allLanguages) { var cultures = allLanguages ? _repository.GetAvailableLanguages() : new[] { CultureInfo.CurrentUICulture }; var allPrompts = new List<Localization.Views.ViewPrompt>(); foreach (var cultureInfo in cultures) { var sf = new SearchFilter { Path = filter }; var prompts = _repository.GetAllPrompts(cultureInfo, cultureInfo, sf); foreach (var prompt in prompts) { if (!allPrompts.Any(x => x.LocaleId == prompt.LocaleId && x.Key == prompt.Key)) allPrompts.Add(prompt); } if (includeCommon) { sf.Path = typeof(CommonPrompts).Name; prompts = _repository.GetAllPrompts(cultureInfo, cultureInfo, sf); foreach (var prompt in prompts) { if (!allPrompts.Any(x => x.LocaleId == prompt.LocaleId && x.Key == prompt.Key)) allPrompts.Add(prompt); } } } return allPrompts.Where(x => !string.IsNullOrEmpty(x.TranslatedText)).ToList(); }
/// <summary> /// Get all prompts that have been created for an language /// </summary> /// <param name="culture">Culture to get translation for</param> /// <param name="templateCulture">Culture to find not translated prompts in (or same culture to disable)</param> /// <param name="filter">Used to limit the search result</param> /// <returns> /// A collection of prompts /// </returns> public IEnumerable<ViewPrompt> GetAllPrompts(CultureInfo culture, CultureInfo templateCulture, SearchFilter filter) { return GetOrCreateLanguage(culture, templateCulture).Prompts.Select(CreatePrompt); }
public ActionResult Index(FilterModel filter) { var cookie = Request.Cookies["ShowMetadata"]; var showMetadata = cookie != null && cookie.Value == "1"; var languages = _repository.GetAvailableLanguages(); if (Request.HttpMethod == "POST" && filter != null) { TableFilter = filter.TableFilter; OnlyNotTranslated = filter.OnlyNotTranslated; } var sf = new SearchFilter(); if (TableFilter != null) sf.Path = TableFilter; if (OnlyNotTranslated) sf.OnlyNotTranslated = true; var prompts = _repository.GetPrompts(CultureInfo.CurrentUICulture, DefaultUICulture.Value, sf).Select( p => new Models.LocalizeTypes.TypePrompt(p)).OrderBy(p => p.TypeName). ToList(); if (!showMetadata) prompts = prompts.Where(p => p.TextName == null || !p.TextName.Contains("_")).ToList(); var model = new IndexModel { Prompts = prompts, Cultures = languages, ShowMetadata = showMetadata, OnlyNotTranslated = OnlyNotTranslated, TableFilter = TableFilter }; return View(model); }