Closed mohamedryan closed 3 years ago
Hi @mohamedryan
It seems you have something wrong with the resource files properties, can you please right click on the resource file and set its build actions as below:
You may check these sample projects with .net 5.0. There is sample project for each resource type (Xml, Db and Resx). And here is a working demo based on Resx project.
The working demo will be available for a limited time only :)
Please let me know if it worked for you.
Hi @LazZiya ,
The file is already made as an embedded resource.
I checked the generated DLL file for the resources, and it looks like this:
Still cannot find the cause for this.
I couldn't reproduce your issue! can you share your repo? also you may try to test with another new project from scratch?
Hi @mohamedryan , any updates regarding your problem? Kindly let me know if you still need any help.
@LazZiya I tested a new project, and it works fine and not get any errors, I searched and applied a lot but still gives this error.
@mohamedryan , Do you mean that the problem is relevant to the old project only? if so can you share the repo to see it?
@LazZiya Sorry for the late reply, I didn't notice the GitHub notifications.
Yes, the problem applies to the old one only.
For the repo, I made a repo and published my project on it; I invented you to the repo, please accept and see what we can do.
Thanks for your efforts.
I'll close this issue since the problem is related to specific configuration in the project and not to XLocalizer
, we can continue discussing in the projects repo.
Kind regards, Ziya
For the benefit of the community, I'm sharing below the findings of our deep diving in this issue.
Best regards, Ziya
Thank you @mohamedryan for the details,
I believe this is normal behavior, as it is not an actual error, it is just handled to return null in case of the key does not exist, so it will return the value of neutral language or the key itself.
Actually when the key dosen't exists it will return the key itself, but if something went wrong (e.g. if the resource file is missing) so it is an error. But in our case it is more similar to a warning than an error that breaks the app.
And to explain why it looks for neutral resource with no culture; it is the default behaviour of the ResourceManager
, first it tries to find the resource in a culture specific file, if not found it will look for the parent culture file, if not found it will look for the neutral file. e.g. lets say that our current culture is ar-AE
, the resource manager will look for the text in below files in order:
EShopingRepo.WebUI.LocalizationResources.LocSource.ar-AE.resources
EShopingRepo.WebUI.LocalizationResources.LocSource.ar.resources
EShopingRepo.WebUI.LocalizationResources.LocSource.resources
For localization, ideally it should find the resource in the first culture specific file, because all localized values should be provided in advance. But when the text is not found in one file it will go to the next file, until it looks in the last one which is neutral (culture free) because it is considered as the root parent for that specific file name. Finally, it will throw a System.Resources.MissingManifestResourceException
because the neutral resource file dosen't exists.
So XLocalizer
will log this as an error, but in production it will not be the case since all keys will be added to the resx file.
I think now we are on a common understanding of the issue.
You may use XmlResourceProvider
with or without MyMemoryTranslateService
to auto add keys and translations during development, and when you are done you can Export XML to RESX
and switch to use RESX in production. This way you can make sure all keys are added to the resources.
Hi, first many thanks to you for your efforts.
I have an issue that happens after I publish my project. These errors are shown in the IIS Event Viewer:
These are my resources:
The container class body:
I found this exists in the csproj file:
The Startup.cs file:
I tried to put this line in csproj file, but nothing happened.
Could you please check and tell me what should I check and do for this?
Thanks.