I am developing an application in Asp.net core that uses some translations depending on the language of the user.
In my controller, I am trying to load the error message from a .resx file. I have multiple ones depending on the language:
Translations.nl.resx
Translations.en.resx
Translations.fr.resx
Translations.resx (default)
I have configured this in the Startup.cs adding the following:
services.AddLocalization();
And in the constructor of my controller i have added:
IStringLocalizer<Translations> localizer
If i build my application in the local machine in Debug or Release mode my translations work as expected. It also works if i build the application with docker-compose but in debug mode.
If i build my application with docker-compose in release mode it is not able to find the expected translation.
My Dockerfile looks like this:
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 60604
EXPOSE 44327
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY MemberDataApi/NuGet.linux.config .
COPY MemberDataApi/MemberDataApi.csproj MemberDataApi/
VOLUME /nuget/myrepo/
COPY MemberDataApi/NugetPackage/ /nuget/myrepo/
RUN dotnet restore MemberDataApi/MemberDataApi.csproj
COPY . .
WORKDIR /src/MemberDataApi
RUN dotnet build MemberDataApi.csproj -c Release -o /app --no-restore
FROM build AS publish
RUN dotnet publish MemberDataApi.csproj -c Release -o /app --no-restore
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MemberDataApi.dll"]
Can i anybody help me with this? Any idea of what is missing on the container or what is wrong