1
0
mirror of synced 2025-01-31 04:13:50 +01:00

Costume name localization

Costume name will now be selected from the right language in the wordlist.
In nijiiro, costume entries for all languages are in japanese, but that gives you the option to translate the fields manually in the wordlist and have it reflected on the webUI.
This commit is contained in:
Farewell_ 2024-10-25 15:51:42 +02:00
parent eb23d4fe13
commit 9bb08e2892
6 changed files with 78 additions and 37 deletions

View File

@ -7,19 +7,7 @@ public class Costume
public string CostumeType { get; init; } = string.Empty;
public string CostumeName { get; init; } = string.Empty;
public override bool Equals(object? obj)
{
if (obj is Costume costume)
{
return costume.CostumeName.Equals(CostumeName) && costume.CostumeType.Equals(CostumeType);
}
return false;
}
public override int GetHashCode()
{
return CostumeName.GetHashCode();
}
public string CostumeNameEN { get; init; } = string.Empty;
public string CostumeNameCN { get; init; } = string.Empty;
public string CostumeNameKO { get; init; } = string.Empty;
}

View File

@ -453,11 +453,17 @@ public class GameDataService(IOptions<DataSettings> dataSettings) : IGameDataSer
var costumeNameKey = $"costume_{cosType}_{costumeId}";
var costumeName = wordlistData.WordListEntries.First(entry => entry.Key == costumeNameKey).JapaneseText;
var costumeNameEn = wordlistData.WordListEntries.First(entry => entry.Key == costumeNameKey).EnglishUsText;
var costumeNameCn = wordlistData.WordListEntries.First(entry => entry.Key == costumeNameKey).ChineseTText;
var costumeNameKo = wordlistData.WordListEntries.First(entry => entry.Key == costumeNameKey).KoreanText;
var costume = new Costume
{
CostumeId = costumeId,
CostumeType = cosType,
CostumeName = costumeName
CostumeName = costumeName,
CostumeNameEN = costumeNameEn,
CostumeNameCN = costumeNameCn,
CostumeNameKO = costumeNameKo,
};
costumeList.Add(costume);
}

View File

@ -33,7 +33,7 @@
else
{
<MudItem xs="12">
<MudTable Items="@songHistoryDataMap.Values.ToList()" Elevation="0" Filter=@FilterSongs Virtualize="true" RowsPerPage="25" Bordered="false" Dense="true" Breakpoint=Breakpoint.None>
<MudTable Class="mud-table-outlined" Items="@songHistoryDataMap.Values.ToList()" Elevation="0" Filter=@FilterSongs Virtualize="true" RowsPerPage="25" Bordered="false" Dense="true" Breakpoint=Breakpoint.None>
<ToolBarContent>
<MudGrid Spacing="2" Justify="Justify.SpaceBetween">
<MudItem xs="12" md="4">

View File

@ -125,35 +125,35 @@
<MudSelect @bind-Value="@response.Head" Label=@Localizer["Head"] AnchorOrigin="Origin.BottomCenter">
@foreach (var index in headUniqueIdList)
{
var costumeTitle = GameDataService.GetHeadTitle(costumeList, index);
var costumeTitle = GameDataService.GetHeadTitle(costumeList, index, CultureInfo.CurrentCulture.ToString());
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Body" Label=@Localizer["Body"] AnchorOrigin="Origin.BottomCenter">
@foreach (var index in bodyUniqueIdList)
{
var costumeTitle = GameDataService.GetBodyTitle(costumeList, index);
var costumeTitle = GameDataService.GetBodyTitle(costumeList, index, CultureInfo.CurrentCulture.ToString());
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Face" Label=@Localizer["Face"] AnchorOrigin="Origin.BottomCenter">
@foreach (var index in faceUniqueIdList)
{
var costumeTitle = GameDataService.GetFaceTitle(costumeList, index);
var costumeTitle = GameDataService.GetFaceTitle(costumeList, index, CultureInfo.CurrentCulture.ToString());
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Kigurumi" Label=@Localizer["Kigurumi"] AnchorOrigin="Origin.BottomCenter">
@foreach (var index in kigurumiUniqueIdList)
{
var costumeTitle = GameDataService.GetKigurumiTitle(costumeList, index);
var costumeTitle = GameDataService.GetKigurumiTitle(costumeList, index, CultureInfo.CurrentCulture.ToString());
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>
<MudSelect @bind-Value="@response.Puchi" Label=@Localizer["Puchi"] AnchorOrigin="Origin.BottomCenter">
@foreach (var index in puchiUniqueIdList)
{
var costumeTitle = GameDataService.GetPuchiTitle(costumeList, index);
var costumeTitle = GameDataService.GetPuchiTitle(costumeList, index, CultureInfo.CurrentCulture.ToString());
<MudSelectItem Value="@index">@index - @costumeTitle</MudSelectItem>
}
</MudSelect>

View File

@ -86,6 +86,7 @@ public class GameDataService : IGameDataService
{
"ja" => musicDetail.SongName,
"en-US" => musicDetail.SongNameEN,
"fr-FR" => musicDetail.SongNameEN,
"zh-Hans" => musicDetail.SongNameCN,
"zh-Hant" => musicDetail.SongNameCN,
"ko" => musicDetail.SongNameKO,
@ -99,6 +100,7 @@ public class GameDataService : IGameDataService
{
"jp" => musicDetail.ArtistName,
"en-US" => musicDetail.ArtistNameEN,
"fr-FR" => musicDetail.ArtistNameEN,
"zh-Hans" => musicDetail.ArtistNameCN,
"zh-Hant" => musicDetail.ArtistNameCN,
"ko" => musicDetail.ArtistNameKO,
@ -136,29 +138,74 @@ public class GameDataService : IGameDataService
};
}
public string GetHeadTitle(IEnumerable<Costume> costumes, uint index)
public string GetHeadTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja")
{
return costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeName ?? string.Empty;
return language switch
{
"jp" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeName ?? string.Empty,
"en-US" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"fr-FR" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"zh-Hans" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"zh-Hant" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"ko" => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeNameKO ?? string.Empty,
_ => costumes.FirstOrDefault(costume => costume.CostumeType == "head" && costume.CostumeId == index)?.CostumeName ?? string.Empty
};
}
public string GetKigurumiTitle(IEnumerable<Costume> costumes, uint index)
public string GetKigurumiTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja")
{
return costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeName ?? string.Empty;
return language switch
{
"jp" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeName ?? string.Empty,
"en-US" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"fr-FR" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"zh-Hans" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"zh-Hant" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"ko" => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeNameKO ?? string.Empty,
_ => costumes.FirstOrDefault(costume => costume.CostumeType == "kigurumi" && costume.CostumeId == index)?.CostumeName ?? string.Empty
};
}
public string GetBodyTitle(IEnumerable<Costume> costumes, uint index)
public string GetBodyTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja")
{
return costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeName ?? string.Empty;
return language switch
{
"jp" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeName ?? string.Empty,
"en-US" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"fr-FR" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"zh-Hans" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"zh-Hant" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"ko" => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeNameKO ?? string.Empty,
_ => costumes.FirstOrDefault(costume => costume.CostumeType == "body" && costume.CostumeId == index)?.CostumeName ?? string.Empty
};
}
public string GetFaceTitle(IEnumerable<Costume> costumes, uint index)
public string GetFaceTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja")
{
return costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeName ?? string.Empty;
return language switch
{
"jp" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeName ?? string.Empty,
"en-US" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"fr-FR" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"zh-Hans" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"zh-Hant" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"ko" => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeNameKO ?? string.Empty,
_ => costumes.FirstOrDefault(costume => costume.CostumeType == "face" && costume.CostumeId == index)?.CostumeName ?? string.Empty
};
}
public string GetPuchiTitle(IEnumerable<Costume> costumes, uint index)
public string GetPuchiTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja")
{
return costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeName ?? string.Empty;
return language switch
{
"jp" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeName ?? string.Empty,
"en-US" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"fr-FR" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeNameEN ?? string.Empty,
"zh-Hans" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"zh-Hant" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeNameCN ?? string.Empty,
"ko" => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeNameKO ?? string.Empty,
_ => costumes.FirstOrDefault(costume => costume.CostumeType == "puchi" && costume.CostumeId == index)?.CostumeName ?? string.Empty
};
}
private async Task InitializeMusicDetailAsync()

View File

@ -28,9 +28,9 @@ public interface IGameDataService
public int GetMusicStarLevel(Dictionary<uint, MusicDetail> musicDetails, uint songId, Difficulty difficulty);
public string GetHeadTitle(IEnumerable<Costume> costumes, uint index);
public string GetKigurumiTitle(IEnumerable<Costume> costumes, uint index);
public string GetBodyTitle(IEnumerable<Costume> costumes, uint index);
public string GetFaceTitle(IEnumerable<Costume> costumes, uint index);
public string GetPuchiTitle(IEnumerable<Costume> costumes, uint index);
public string GetHeadTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja");
public string GetKigurumiTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja");
public string GetBodyTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja");
public string GetFaceTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja");
public string GetPuchiTitle(IEnumerable<Costume> costumes, uint index, string? language = "ja");
}