Interface ILocalizationService
Interface for managing localization resources, including retrieving, updating, and caching resources.
Namespace: DataWeb.Localization
Assembly: DataWeb.Core.dll
Syntax
public interface ILocalizationService
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
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
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
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
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
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
string GetDefaultFallbackCulture()
Returns
Type | Description |
---|---|
string | The default fallback culture. |
GetFallbackCulture(string)
Gets the fallback culture for the specified culture.
Declaration
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
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
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
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
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 from the resource store and converting them to a dictionary.
Declaration
Task InitCachedResources()
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
RemoveResourceAsync(string)
Removes the resource with the specified Id.
Declaration
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
Task SetResourceAsync(Resource resource)
Parameters
Type | Name | Description |
---|---|---|
Resource | resource | The Resource to set in the store. |
Returns
Type | Description |
---|---|
Task |