Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!