Description
Description
Our app have a method to return a localized list of time zones (simplified):
public IActionResult GetAllTimeZone(string lang = "") {
var reqCult = CultureInfo.GetCultureInfo(lang);
CultureInfo.CurrentUICulture = reqCult;
CultureInfo.CurrentCulture = reqCult;
CultureInfo.DefaultThreadCurrentUICulture = reqCult;
CultureInfo.DefaultThreadCurrentCulture = reqCult;
TimeZoneInfo.ClearCachedData();
return _mapper.Map<TimeZoneInfoDto[]>(TimeZoneInfo.GetSystemTimeZones());
}
We were using .net 6.0 in docker (Linux)
Calling it with "en", "de", "zh" produced expected results.
However when we upgraded to .net 8.0 the same code broke. It now produces always the same results not respecting CultureInfo.CurrentUICulture
.
Reproduction Steps
Create minimal api project with one method that returns TimeZoneInfo.GetSystemTimeZones()
as described earlier
Expected behavior
List of timezones with localized display names
Actual behavior
List of timezones with display names of the OS locale. When running in container it returns always English names. On dev machine it uses the OS locale.
Regression?
No response
Known Workarounds
No response
Configuration
Dev machine
dotnet SDK
Version: 8.0.115
Commit: 9c0387c3ea
Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: ubuntu.24.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.115/
Host:
Version: 8.0.15
Architecture: x64
Commit: 50c4cb9
.NET SDKs installed:
6.0.136 [/usr/lib/dotnet/sdk]
8.0.115 [/usr/lib/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.15 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.15 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Other information
No response