Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda