public string Invoke(Lot lot, IViewLocalizer localizer) { TimeSpan left = lot.Ending - DateTime.Now; if (left.TotalDays > 1) { return($"{localizer["Left"].Value }: {((int)left.TotalDays).ToString()} {localizer["day"].Value}"); } else if (left.TotalHours > 1) { return($"{localizer["Left"].Value }: {((int)left.TotalHours).ToString()} {localizer["hour"].Value}"); } else if (left.TotalMinutes > 1) { return($"{localizer["Left"].Value }: {((int)left.TotalHours).ToString()} {localizer["minute"].Value}"); } else if (left.TotalSeconds > 1) { return(localizer["LessThanMinute"].Value); } else { return(localizer["BiddingCompleted"].Value); } }
public static string GetString(this IHtmlHelper helper, string key) { IServiceProvider services = helper.ViewContext.HttpContext.RequestServices; IViewLocalizer localizer = services.GetRequiredService <IViewLocalizer>(); return localizer[key] }
public static LocalizedHtmlString Plural(this IViewLocalizer localizer, int count, string singular, string plural, params object[] arguments) { if (plural == null) { throw new ArgumentNullException(nameof(plural), "Plural text can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extention."); } return(localizer[singular, new PluralizationArgument { Count = count, Forms = new[] { singular, plural }, Arguments = arguments }]); }
public DbGroupVnController( IViewLocalizer localizer, IOptions <RequestLocalizationOptions> localizationOptions, IMenuHelper menuHelper, UserManager <User> userManager ) { _localizer = localizer; _localizationOptions = localizationOptions; _menuHelper = menuHelper; }
public IndexModel(PoolControl poolControl, IViewLocalizer localizer) { this.State = poolControl.GetPoolControlInformation(); this.GeneralState = GeneralState.ConvertFromPoolState(poolControl.GetPoolControlInformation()); this.TemperatureRunTime = this.State.PoolSettings.TemperatureRunTime.ToArray(); this.PumpingCycles = this.State.PoolSettings.WorkingMode == PoolWorkingMode.Summer ? this.State.PoolSettings.SummerPumpingCycles : this.State.PoolSettings.WinterPumpingCycles; var chartOptions = new Highcharts { Title = new Title { Text = "" }, XAxis = new List <XAxis>() { new XAxis() { Title = new XAxisTitle() { Text = "°C" } } }, YAxis = new List <YAxis>() { new YAxis() { Title = new YAxisTitle() { Text = "h" } } }, Series = new List <Series>() { new AreaSeries { Name = "h", Data = this.State.PoolSettings.TemperatureRunTime .Select(d => new AreaSeriesData() { X = d.Temperature, Y = d.RunTimeHours }) .ToList(), } } }; chartOptions.ID = "chart"; this.ChartRenderer = new HighchartsRenderer(chartOptions); }
public string Invoke(Lot lot, IViewLocalizer localizer) { return(String.Format("{0}, {1}, {2} {3}., {4}, {5}, {6} {7}.", lot.Year, transmission[lot.Transmission], lot.EngineVolume.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")), localizer["liter"].Value, fuel[lot.Fuel], body[lot.Body], lot.Milleage, localizer["km"].Value)); }
public ItemController(UserManager <IdentityUser> userManager, IItemService itemService, ICategoryService itemCategoryService, IItemImageService itemImageService, IColorService colorService, IMapper mapper, IHostingEnvironment hostingEnvironment, IViewLocalizer localizer, ICityService cityService) { _itemService = itemService; _colorService = colorService; _itemImageService = itemImageService; _itemCategoryService = itemCategoryService; _mapper = mapper; _userManager = userManager; _hostingEnvironment = hostingEnvironment; _localizer = localizer; _cityService = cityService; }
public static LocalizedHtmlString Plural(this IViewLocalizer localizer, int count, string[] pluralForms, params object[] arguments) { if (pluralForms == null) { throw new ArgumentNullException(nameof(pluralForms), "PluralForms array can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extention."); } if (pluralForms.Length == 0) { throw new ArgumentException(nameof(pluralForms), "PluralForms array can't be empty, it must contain at least one element. If you don't want to specify the plural text, use IStringLocalizer without Plural extention."); } return(localizer[pluralForms[0], new PluralizationArgument { Count = count, Forms = pluralForms, Arguments = arguments }]); }
public static string Plural(this IViewLocalizer localizer, string key, int number) { var provider = PluralHelper.GetPluralChooser(CultureInfo.CurrentCulture); var pluralType = provider.ComputePlural(number); string selectedSentence = null; try { switch (pluralType) { case PluralTypeEnum.ZERO: selectedSentence = localizer.GetString(key + "_Zero"); break; case PluralTypeEnum.ONE: selectedSentence = localizer.GetString(key + "_One"); break; case PluralTypeEnum.OTHER: selectedSentence = localizer.GetString(key + "_Other"); break; case PluralTypeEnum.TWO: selectedSentence = localizer.GetString(key + "_Two"); break; case PluralTypeEnum.FEW: selectedSentence = localizer.GetString(key + "_Few"); break; case PluralTypeEnum.MANY: selectedSentence = localizer.GetString(key + "_Many"); break; default: throw new ArgumentOutOfRangeException(); } } catch { // ignored } return(selectedSentence != null?string.Format(selectedSentence, number) : ""); }
public static LocalizedHtmlString Pluralize(this IViewLocalizer localizer, string key, bool isPlural) { var resource = localizer[key]; if (resource.IsResourceNotFound) { return(resource); } if (!resource.Value.Contains("|")) { throw new ArgumentException("The resource values must contain a pipe (|) separated pair of values."); } var parts = resource.Value.Split('|', StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { throw new ArgumentException("The resource values must contain a pipe (|) separated pair of values."); } return(isPlural ? new LocalizedHtmlString(key, parts[1]) : new LocalizedHtmlString(key, parts[0])); }
public static LocalizedHtmlString GetQuantityString(this IViewLocalizer localizer, string key, int quantity, params object[] args) { return(localizer.GetQuantityString(key, (long)quantity, args)); }
/// <summary> /// Instantiates the model. /// </summary> /// <param name="client">The client used to communicate with the Contentful API.</param> /// <param name="visitedLessonsManager">Class manages which lessons and courses have been visited.</param> /// <param name="breadcrumbsManager">Class that manages which breadcrumbs the view should display.</param> public LessonsModel(IContentfulClient client, IVisitedLessonsManager visitedLessonsManager, IBreadcrumbsManager breadcrumbsManager, IViewLocalizer localizer) : base(client) { _visitedLessonsManager = visitedLessonsManager; _breadcrumbsManager = breadcrumbsManager; _localizer = localizer; }
public string Invoke(CarLot lot, IViewLocalizer localizer) { TimeSpan left = lot.Ending - DateTime.UtcNow; return($"{left.Days} {localizer["D"].Value}. : {left.Hours} {localizer["H"].Value}. : {left.Minutes} {localizer["M"].Value}."); }
/// <summary> /// Initializes the view component. /// </summary> /// <param name="localizer">The localizer to localize the title with.</param> public MetaTagsViewComponent(IViewLocalizer localizer) { _localizer = localizer; }
private IEnumerable <ValidationResult> MakeTestCalls(HttpClient httpClient, IContentfulClient contentfulClient, IViewLocalizer localizer) { ValidationResult validationResult = null; try { var space = contentfulClient.GetSpace().Result; } catch (AggregateException ae) { ae.Handle((ce) => { if (ce is ContentfulException) { if ((ce as ContentfulException).StatusCode == 401) { validationResult = new ValidationResult(localizer["deliveryKeyInvalidLabel"].Value, new[] { nameof(AccessToken) }); } else if ((ce as ContentfulException).StatusCode == 404) { validationResult = new ValidationResult(localizer["spaceOrTokenInvalid"].Value, new[] { nameof(SpaceId) }); } else { validationResult = new ValidationResult($"{localizer["somethingWentWrongLabel"].Value}: {ce.Message}", new[] { nameof(AccessToken) }); } return(true); } return(false); }); } if (validationResult != null) { yield return(validationResult); } contentfulClient = new ContentfulClient(httpClient, AccessToken, PreviewToken, SpaceId, true); try { var space = contentfulClient.GetSpace().Result; } catch (AggregateException ae) { ae.Handle((ce) => { if (ce is ContentfulException) { if ((ce as ContentfulException).StatusCode == 401) { validationResult = new ValidationResult(localizer["previewKeyInvalidLabel"].Value, new[] { nameof(PreviewToken) }); } else if ((ce as ContentfulException).StatusCode == 404) { validationResult = new ValidationResult(localizer["spaceOrTokenInvalid"].Value, new[] { nameof(SpaceId) }); } else { validationResult = new ValidationResult($"{localizer["somethingWentWrongLabel"].Value}: {ce.Message}", new[] { nameof(PreviewToken) }); } return(true); } return(false); }); } if (validationResult != null) { yield return(validationResult); } }
/// <summary> /// Instantiates the model. /// </summary> /// <param name="client">The client used to communicate with the Contentful API.</param> /// <param name="breadcrumbsManager">Class that manages which breadcrumbs the view should display.</param> public CoursesModel(IContentfulClient client, IBreadcrumbsManager breadcrumbsManager, IViewLocalizer localizer) : base(client) { _breadcrumbsManager = breadcrumbsManager; _localizer = localizer; }
public DynamicViewLocalizer(IViewLocalizer localizer) : base(localizer) { Localizer = localizer; }
public static LocalizedHtmlString GetQuantityString(this IViewLocalizer localizer, string key, long quantity, params object[] args) { var normalizedQuantity = LocalizerExtensions.GetNormalizedQuantity(quantity); return(localizer[$"{key}_{normalizedQuantity}", args]); }
public UseViewLocalizerModel(IViewLocalizer viewLocalizer) { _viewLocalizer = viewLocalizer; }
/// <summary> /// Initializes a new <see cref="Breadcrumbs"/> middleware component. /// </summary> /// <param name="next">The next request delegate in the chain of middleware.</param> /// <param name="localizer">The localizer used to localize the breadcrumbs.</param> public Breadcrumbs(RequestDelegate next, IViewLocalizer localizer) { _next = next; _localizer = localizer; }