LazZiya / XLocalizer

Localizer package for Asp.Net Core web applications, powered by online translation and auto resource creating.
https://docs.ziyad.info
129 stars 14 forks source link

XLocalizer.Resx.ResxResourceProvider #36

Closed faresayyad closed 2 years ago

faresayyad commented 2 years ago

I am getting an error in the event viewer. every time I switch from English to Arabic

Category: XLocalizer.Resx.ResxResourceProvider EventId: 0 SpanId: 0045c129f6cb0af8 TraceId: 8363e0583dfeb1894b13492b134b631c ParentId: 0000000000000000 RequestId: 8000457b-0000-ed00-b63f-84710c7967bb RequestPath: /ar/Aboutus ActionId: 3f0a219e-baf9-426f-909d-f0ae59dd2874 ActionName: MP.Web.Controllers.HomeController.AboutUs (MP.Web)

Could not find the resource "MP.Web.LocalizationResources.LocSource.resources" among the resources "" embedded in the assembly "MP.Web", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name.

Do you have any idea what it's about.?

LazZiya commented 2 years ago

Do you have the folder "LocalizationResources" exists? if not create it and retry.

faresayyad commented 2 years ago

Yes it was created. image the issue exist.

LazZiya commented 2 years ago

I mean in the server "hosting" side :)

faresayyad commented 2 years ago

Oh, It seems working fine now after adding the folder.

LazZiya commented 2 years ago

Good to know it is working now! Closing this issue since it is solved :)

faresayyad commented 2 years ago

It seems that the same issue appeared again, the folder exists in the production. image

faresayyad commented 1 year ago

Is there any solution or do you have an idea?

LazZiya commented 1 year ago

unfortunately I am fully occupied, and can't afford time for github nowadays :(

Any PR are welcome :)

LazZiya commented 1 year ago

@faresayyad, I can't reproduce your issue, can you share your project startup? and have you seen the samples projects?

faresayyad commented 1 year ago

Yes sure,

image

LazZiya commented 1 year ago

Well, now I can better understand your problem! Before I explain the solution I recommend to read the docs about XLocalizer with RESX files:

RESX files do not support editing at runtime! So if you do not want to fill them manually, start localization setup based on XML or DB, then export the resources to RESX files.


The Solution:

If you want to use RESX files, either create them manually or :

  1. Follow XLocalizer with XML setup, below steps are missing in your startup:
    
    // add xml resource provider
    services.AddSingleton<IXResourceProvider, XmlResourceProvider>();

// add translation service services.AddHttpClient<ITranslator, MyMemoryTranslateService>();


2. Run your application and make sure that all translations are done properly.

_Next steps are optional_

3. Export the resources from [XML to RESX](https://docs.ziyad.info/en/XLocalizer/v1.0/export-xml-to-resx.md)
4. Switch to RESX resource files by removing the XML resource provider and translation service setup from startup.

Read more in the [best practice and recommendations page](https://docs.ziyad.info/en/XLocalizer/v1.0/best-practice.md) page will help.
faresayyad commented 1 year ago

But i already have the Resx file for Arabic and I fill them manually image

LazZiya commented 1 year ago

what is the build action of the resource files? (right click and see properties)

image

faresayyad commented 1 year ago

image

LazZiya commented 1 year ago

Did you tested with different build action settings?