Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orchardcore can work well in my local windows , but doesn't work in remote Linux docker,what's the problem ? i mean the app runs well, only localization doesn't work well. #16497

Closed
freepay2020 opened this issue Jul 28, 2024 · 9 comments

Comments

@freepay2020
Copy link

freepay2020 commented Jul 28, 2024

Orchardcore can work well in my local windows , but doesn't work in remote Linux docker,what's the problem ? i mean the app runs well, only localization doesn't work well.

Orchard Core version 1.6 for .net core 6

using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc.Razor;
using System.Globalization;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPortableObjectLocalization(options => options.ResourcesPath = "Resources");
builder.Services.AddPortableObjectLocalization();
builder.Services.Configure<RequestLocalizationOptions>(options =>
{
    var supportedCultures = new List<CultureInfo>
            {
                new CultureInfo("en-US"),
                new CultureInfo("en"),
                new CultureInfo("fr-FR"),
                new CultureInfo("fr"),
                new CultureInfo("zh")
            };

    options.DefaultRequestCulture = new RequestCulture("zh");
    options.SupportedCultures = supportedCultures;
    options.SupportedUICultures = supportedCultures;
});
builder.Services.AddMvc()
        .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);

// Add services to the container.
builder.Services.AddRazorPages();

var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

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

//where you are
app.UseRouting();
//who you are
app.UseAuthentication();
//what you can do
app.UseAuthorization();

app.MapControllers();
app.MapRazorPages();
await app.RunAsync();

To Reproduce

Steps to reproduce the behavior:

  1. i set up all well and it runs well in my local windows linux docker correctly, but when i upload into remote server linux,run in docker,it doesn't work, the app runs well, only localization doesn't work well
  2. the app runs without any errors, only cannot get localization expected.

Expected behavior

  1. i set up all well and it runs well in my local windows linux docker correctly, but when i upload into remote server linux,run in docker,it doesn't work, the app runs well, only localization doesn't work well
  2. the app runs without any errors, only cannot get localization expected.

Logs and screenshots

If applicable, add log files, browser console logs, and screenshots (or screen recording videos) to help explain your problem.

Copy link
Contributor

Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. On what happens next, see the docs.

If you like Orchard Core, please star our repo and join our community channels.

@MikeAlhayek
Copy link
Member

Most of the code you posted is not need and should be removed. Follow the setup described here https://docs.orchardcore.net/en/latest/getting-started/

Enable the Localization feature for the tenant and you should be able to see the site in other languages. @hishamco is more familiar with localization, he may be add more info.

@sebastienros
Copy link
Member

Actually I think the issue is about the localization package we ship (po files + pluralization support) and not the CMS part (or modularity/tenants).

For reference, the documentation on how to use this package
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/portable-object-localization?view=aspnetcore-8.0

@sebastienros sebastienros added this to the 2.x milestone Aug 1, 2024
Copy link
Contributor

github-actions bot commented Aug 1, 2024

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@hishamco
Copy link
Member

hishamco commented Aug 2, 2024

@freepay2020 why did you configure RequestLocalizationOptions again? it should be done in OC by default. Please share a repo to reproduce the issue

Actually I think the issue is about the localization package we ship (po files + pluralization support) and not the CMS part (or modularity/tenants).

I don't think there's an issue, I'm updating the localization sample in AspNet Docs frequently, let me do it for the last version then confirm

@tangxiaoyu
Copy link

Re-add and set up localization in the background.

@sebastienros
Copy link
Member

I can find of two reasons this would fail:
0. zh might not be a known culture on Linux in .NET (but this should be a good fallback value for zh-CN and zh-TW)
0. The paths are case sensitive and the folders you created don't match what Orchard is expecting

Can you check both?

Copy link
Contributor

It seems that this issue didn't really move for quite a while despite us asking the author for further feedback. Is this something you'd like to revisit any time soon or should we close? Please reply.

@github-actions github-actions bot added the stale label Sep 20, 2024
Copy link
Contributor

Closing this issue because it didn't receive further feedback from the author for very long. If you think this is still relevant, feel free to reopen it with the requested details.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2024
@MikeAlhayek MikeAlhayek modified the milestones: 2.x, 2.1 Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants