Class LocalizationService
Represents a service for managing localization resources.
Implements
Inherited Members
Namespace: DataWeb.Localization
Assembly: DataWeb.Core.dll
Syntax
public class LocalizationService : ILocalizationService
Constructors
LocalizationService(IResourceStore, IConfigurationService)
Initializes a new instance of the LocalizationService class.
Declaration
public LocalizationService(IResourceStore resourceStore, IConfigurationService configurationService)
Parameters
Type | Name | Description |
---|---|---|
IResourceStore | resourceStore | The IResourceStore to use for retrieving and saving resources. |
IConfigurationService | configurationService | The configuration service to use for retrieving application settings. |
Properties
CachedResources
Gets or sets the dictionary of cached resources, where the key is the resource name, and the value is a dictionary of culture values.
Declaration
public FrozenDictionary<string, Dictionary<string, string>> CachedResources { get; set; }
Property Value
Type | Description |
---|---|
FrozenDictionary<string, Dictionary<string, string>> |
FallbackCultures
Gets or sets the dictionary of fallback cultures, where the key is the culture, and the value is the fallback culture.
Declaration
public FrozenDictionary<string, string> FallbackCultures { get; set; }
Property Value
Type | Description |
---|---|
FrozenDictionary<string, string> |
Methods
ConvertStatus(string)
Converts the given value to a resource status.
Declaration
public ResourceStatus ConvertStatus(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value |
Returns
Type | Description |
---|---|
ResourceStatus |
DeserializeCultureItems(string)
Deserializes a string value into a list of Resource.CultureItem objects.
Declaration
public List<Resource.CultureItem> DeserializeCultureItems(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string value to deserialize. |
Returns
Type | Description |
---|---|
List<Resource.CultureItem> | A list of Resource.CultureItem objects. |
GetCultureResources(string, string[])
Gets the culture resources for the specified culture and contexts.
Declaration
public Dictionary<string, string> GetCultureResources(string culture, string[] contexts)
Parameters
Type | Name | Description |
---|---|---|
string | culture | The culture for which to get the resources. |
string[] | contexts | The resource contexts for which to get the resources. |
Returns
Type | Description |
---|---|
Dictionary<string, string> | A dictionary of resource keys and values for the specified culture and contexts. |
GetDefaultFallbackCulture()
Gets the default fallback culture.
Declaration
public string GetDefaultFallbackCulture()
Returns
Type | Description |
---|---|
string | The default fallback culture. |
GetFallbackCulture(string)
Gets the fallback culture for the specified culture.
Declaration
public string GetFallbackCulture(string culture)
Parameters
Type | Name | Description |
---|---|---|
string | culture | The culture for which to get the fallback culture. |
Returns
Type | Description |
---|---|
string | The fallback culture for the specified culture. |
GetResourceAsync(ResourceFilter)
Gets a resource matching the specified filter.
Declaration
public Task<Resource> GetResourceAsync(ResourceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ResourceFilter | filter | The ResourceFilter to apply to the resources. |
Returns
Type | Description |
---|---|
Task<Resource> | The resource matching the specified filter, or null if no match was found. |
GetResourceContextsAsync()
Gets all the distinct resource contexts in the system.
Declaration
public Task<IEnumerable<string>> GetResourceContextsAsync()
Returns
Type | Description |
---|---|
Task<IEnumerable<string>> | A list of all the distinct resource contexts in the system. |
GetResourceCountAsync(ResourceFilter)
Gets the count of resources matching the specified filter.
Declaration
public Task<long> GetResourceCountAsync(ResourceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ResourceFilter | filter | The ResourceFilter to apply to the resources. |
Returns
Type | Description |
---|---|
Task<long> | The count of resources matching the specified filter. |
GetResourcesAsync(ResourceFilter)
Gets the resources matching the specified filter.
Declaration
public Task<IEnumerable<Resource>> GetResourcesAsync(ResourceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ResourceFilter | filter | The ResourceFilter to apply to the resources. |
Returns
Type | Description |
---|---|
Task<IEnumerable<Resource>> | The resources matching the specified filter. |
InitCachedResources()
Initializes the CachedResources dictionary by getting all resources and converting them to a dictionary.
Declaration
public Task InitCachedResources()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
RemoveResourceAsync(string)
Removes the resource with the specified Id.
Declaration
public Task RemoveResourceAsync(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id | The Id of the resource to remove. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
SetResourceAsync(Resource)
Sets the specified resource in the store.
Declaration
public Task SetResourceAsync(Resource resource)
Parameters
Type | Name | Description |
---|---|---|
Resource | resource | The Resource to set in the store. |
Returns
Type | Description |
---|---|
Task |