This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 459
This repository was archived by the owner on May 1, 2024. It is now read-only.
[Enhancement] Localization manager with more than one resource manager #832
Copy link
Copy link
Closed
Labels
feature-requestA request for a new feature.A request for a new feature.needs-approvalFeature request has been submitted but is awaiting final approval. Please do not implement before!Feature request has been submitted but is awaiting final approval. Please do not implement before!
Description
Summary
Currently the localization manager (singleton) can be initialized only with one resource manager. This is often not enough.
We ceurrently use own implementation for this purpose, that accept a list of resource managers (form common library, different app modules).
API Changes
Non breaking changes:
Line 16 in f62c078
ResourceManager resourceManager; |
ResourceManager[] resourceManagers = new ResourceManager[0];
Lines 25 to 32 in f62c078
public void Init(ResourceManager resource) => | |
resourceManager = resource; | |
public void Init(ResourceManager resource, CultureInfo initialCulture) | |
{ | |
resourceManager = resource; | |
currentCulture = initialCulture; | |
} |
public void Init(params ResourceManager[] resources) =>
resourceManagers = resources;
public void Init(ResourceManager resource, CultureInfo initialCulture)=>
Init(initialCulture, resource);
public void Init(CultureInfo initialCulture, params ResourceManager[] resources)
{
resourceManagers = resources;
currentCulture = initialCulture;
}
Lines 34 to 35 in f62c078
public string GetValue(string text) => | |
resourceManager.GetString(text, CurrentCulture); |
public string GetValue(string text)
{
string translated = null;
foreach (var rm in resourceManagers)
{
translated = rm.GetString(text, CurrentCulture);
if (translated != null)
{
break;
}
}
return translated;
// Or as LINQ
// return resourceManagers.Select(s => s.GetString(text, CurrentCulture))
// .FirstOrDefault(f => f != null);
}
Intended Use Case
Usage with more than one resource manager.
Who Will Do The Work?
- I am willing to take this on myself
- Just putting this out there for someone to pick up
AmrAlSayed0, maxkoshevoi and sawankumarbundelkhandi
Metadata
Metadata
Assignees
Labels
feature-requestA request for a new feature.A request for a new feature.needs-approvalFeature request has been submitted but is awaiting final approval. Please do not implement before!Feature request has been submitted but is awaiting final approval. Please do not implement before!