Shows main culture first
This commit is contained in:
parent
189b1600f6
commit
9ae1111f9e
@ -24,8 +24,27 @@ public partial class Translations : UserControl
|
|||||||
if(this.DesignMode)
|
if(this.DesignMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var cultureInfos = await AppSettings.GetCultureInfos();
|
// Apply a custom order for the cultures. We want to show the default culture first,
|
||||||
foreach (var cultureInfo in cultureInfos.OrderByDescending(n => n.Index))
|
// then the other cultures in order of their index. Please note: whatever we want to
|
||||||
|
// show as first, we have to return last!
|
||||||
|
async IAsyncEnumerable<AppSettings.CultureInfo> DesiredOrder()
|
||||||
|
{
|
||||||
|
// Get all configured cultures:
|
||||||
|
var cultureInfos = (await AppSettings.GetCultureInfos()).OrderByDescending(n => n.Index).ToList();
|
||||||
|
|
||||||
|
// Get the main culture:
|
||||||
|
var mainCultureIndex = await AppSettings.GetDeepLSourceCultureIndex();
|
||||||
|
|
||||||
|
// First, we return all the non-main cultures in descending order of their index:
|
||||||
|
foreach (var cultureInfo in cultureInfos.Where(n => n.Index != mainCultureIndex))
|
||||||
|
yield return cultureInfo;
|
||||||
|
|
||||||
|
// Last, we return the main culture:
|
||||||
|
if(cultureInfos.Any(n => n.Index == mainCultureIndex))
|
||||||
|
yield return cultureInfos.First(n => n.Index == mainCultureIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
await foreach (var cultureInfo in DesiredOrder())
|
||||||
{
|
{
|
||||||
var translationComponent = new Translation(cultureInfo.Code);
|
var translationComponent = new Translation(cultureInfo.Code);
|
||||||
this.translationComponents.Add(cultureInfo.Code, translationComponent);
|
this.translationComponents.Add(cultureInfo.Code, translationComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user