I have an application that need to translate date. When using VS2022, I'm able to switch between languages when changing a entry parameter. When I run the docker container containing my app, dates are not localized and only English is supported by default
Here my dockerfile : `
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS publish
WORKDIR /src
COPY myApp/. .
RUN dotnet restore myApp.sln
WORKDIR /src/myApp
RUN dotnet publish -c Release -o /app
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
WORKDIR /app
EXPOSE 80
COPY --from=publish /app .
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
RUN apk add --no-cache icu-libs
ENTRYPOINT ["dotnet", "myApp.dll"]
I also tried by switching
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
`
When executing myDate.ToString("dddd dd MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")), the date is returned in english instead of french
1条答案
按热度按时间8yparm6h1#
It turns out that icu-libs no longer contains all cultures.
You need to add:
RUN apk add --no-cache icu-data-full
For more information, take a look here: https://github.com/dotnet/dotnet-docker/issues/3844