Git Product home page Git Product logo

Comments (10)

LazZiya avatar LazZiya commented on May 13, 2024

@Malkawi1

Check if you have a culture paramter setup already made in page route, if so remove it because the code below is already adding the culture parameter to all routes.

.AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))

Or delete the above line if you want to use your own culture parameter setup.

from xlocalizer.

Malkawi1 avatar Malkawi1 commented on May 13, 2024

@LazZiya

After remove this line -> .AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))

when choosing language -> error

This localhost page can’t be foundNo webpage was found for the web address: https://localhost:44349/ar
HTTP ERROR 404

from xlocalizer.

LazZiya avatar LazZiya commented on May 13, 2024

After removing that line you need to manually add the culture parameter to the routes {culture}

from xlocalizer.

Malkawi1 avatar Malkawi1 commented on May 13, 2024

add to this line -> like this
<language-nav cookie-handler-url="@Url.Action("SetCultureCookie", "Home", "{culture}",new { area="", cltr="{0}", returnUrl="{1}", culture=CultureInfo.CurrentCulture.Name })">

from xlocalizer.

LazZiya avatar LazZiya commented on May 13, 2024

So if it is ok now we can close this issue, is it?

from xlocalizer.

Malkawi1 avatar Malkawi1 commented on May 13, 2024

@LazZiya

sir,
when using the package LazZiya.ExpressLocalization

after running the code shown in this route ->
https://localhost:44349/en/Identity/Account/Login/?ReturnUrl=/en/

so, this route is wrong and this true route -> https://localhost:44349/Account/Login/?culture=en

so how to edit my route to be true
#note I'm using .net 6
and this is my code in program.cs

CultureInfo us = new CultureInfo("en-US");
var cultures = new CultureInfo[]
{ new CultureInfo("en"),
new CultureInfo("ar")
{ DateTimeFormat = us.DateTimeFormat } };

// Add services to the container.
builder.Services.AddControllersWithViews()

.AddExpressLocalization<LocSource>(
        ops =>
        {
            ops.ResourcesPath = "LocalizationResources";
            ops.RequestLocalizationOptions = o =>
            {
                o.SupportedCultures = cultures;
                o.SupportedUICultures = cultures;
                o.DefaultRequestCulture = new RequestCulture("en");
            };

        });

app.UseRequestLocalization();

from xlocalizer.

LazZiya avatar LazZiya commented on May 13, 2024

Well, I see you are using LazZiya.ExpressLocalization, I recommend you switch to XLocalizer, it is much better in terms of flexibility and provides better support for newer frameworks.

from xlocalizer.

Malkawi1 avatar Malkawi1 commented on May 13, 2024

After removing that line you need to manually add the culture parameter to the routes {culture}

@LazZiya

how invested this lin by parameter {culture}
.AddMvcOptions(ops => ops.Conventions.Insert(0, new RouteTemplateModelConventionMvc()))

please tell me step by step

from xlocalizer.

LazZiya avatar LazZiya commented on May 13, 2024

With reference to XLocalizer version of RouteTemplateModelConventionMvc(), it adds a route parameter named {culture?} to all routes in the app, so you don't have to add it manually to each route in the routing table.

// e.g.:
[controller]/[action] --> {culture?}/[controller]/[action]

from xlocalizer.

LazZiya avatar LazZiya commented on May 13, 2024

Hi @Malkawi1 ,

Do you still need support with this issue?

from xlocalizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.