LocalizationProvider Class
Provides access to the current localization provider for RelativeDate formatting.
public static class LocalizationProviderExample
Implement ILocalizationProvider:
private sealed class UpperCaseLocalizationProvider : ILocalizationProvider
{
public string GetString(string name, CultureInfo? culture)
{
return ResxLocalizationProvider.Instance.GetString(name, culture).ToUpperInvariant();
}
}Use it for all RelativeDate instances:
// Use custom localization provider
LocalizationProvider.Current = new UpperCaseLocalizationProvider();
var date = RelativeDate.Get(DateTime.UtcNow.AddHours(-2));
Assert.Equal("2 HOURS AGO", date.ToString(null, CultureInfo.InvariantCulture));
// Restore default
LocalizationProvider.Current = ResxLocalizationProvider.Instance;Properties
| Name | Description |
|---|---|
| Current | Gets or sets the current localization provider used by RelativeDate. |
Current
LocalizationProvider.csGets or sets the current localization provider used by RelativeDate.
public static ILocalizationProvider Current { get; set; }Property value
ILocalizationProvider The current ILocalizationProvider. The default is ResxLocalizationProvider.
Exceptions
ArgumentNullException- Thrown when attempting to set the value to
null.