本地化在dotnet6 aspnet alpine docker图像上不起作用

n8ghc7c1  于 2022-12-11  发布在  Docker
关注(0)|答案(1)|浏览(136)

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

8yparm6h

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

相关问题