Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
Localization is not working building the application in Release mode with docker-compose (Docker for Linux) in VS2017

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

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I had the same issue and spent hours tyring to fix something that wasn't broken because everything was working perfectly fine locally and thought it was due to containerization.

Actually I had to add those lines in my Configure(IApplicationBuilder app, IWebHostEnvironment env) method in Startup.cs:

var supportedCultures = new string[] { "en-US", "fr-FR" };
app.UseRequestLocalization(options =>
    options
        .AddSupportedCultures(supportedCultures)
        .AddSupportedUICultures(supportedCultures)
        .SetDefaultCulture("fr-FR")
);

You must precise which cultures your application can handle.

You can find more here.

over 4 years ago · Santiago Trujillo Relatório

0

We had the same issue. It always works on my windows machine but doesn't work on linux server after deployment. It turns out we had to include both:

.AddSupportedCultures(supportedCultures);
.AddSupportedUICultures(supportedCultures);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda