-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Please add more info about shared files #28674
Comments
@hishamco PLEASE review |
What about this one https://learn.microsoft.com/en-us/aspnet/core/fundamentals/localization/make-content-localizable?view=aspnetcore-7.0#shared-resources If I remembered we already have a sample for shared resources, please check the samples in the repo |
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
I've looked at the samples here https://github.com/aspnet/Entropy/tree/master/samples with 'localization' in the name, and could not find anything. I saw the section about SharedResources, that's how I knew it was possible to use them. But there is no information about how to structure the folders and files and namespaces an that in services.AddLocalization, no Path should be entered. |
The
Have a look to this Lines 66 to 68 in 46ec24e
|
Now I'm completely confused why I had to remove the Path to get it to work but ok. The sample has an unused file, btw: Resources.SharedResource.fr.resx. Thanks |
Which path do you mean?
Don't blow my mind :) Line 12 in 46ec24e
As I told you it's just a marker or dummy class |
I know it's a dummy class, that was the first thing I implemented. This Path When I set it to "Resources" (which is where my .resx files actually are), it searched at My SharedResources class is in the Resources directory, too (but in the project namespace) but I had the same problem when I put it into the project root. Not setting a ResourcesPath is suggested in the stackoverflow thread so I tried that and it worked. But it seems that's not the only way to make it work, as shown by the sample. |
When you set the path as it was shown, it should look for the resources inside that folder, unless you did something wrong with the namespaces I don't know if you are working on another project, but I'm pretty sure it might be namespace issue. Could you please share a minimal repo to reproduce the issue? |
Which of the resources doesn't work probably? Just to avoid check everything in the project |
Both. It's hardcoded to use French but the result is the same if English is used. |
I just found two issues here:
Two of the craziest issues in localization are resource naming and namespaces :) |
Just the |
Please update your repo, then give me access write to it, so I can commit directly |
@Edelbitter check your repo now, as I told you before naming is critical in localization :) You might check the troubleshooting section in our docs. @Rick-Anderson is there anything to add here or we can close this one |
I'll remember never to use hyphens for anything! Thank you for your time :) |
Not only hyphens, any invalid symbol :) |
@hishamco that helped me too, I spent more than 4 hours before, your solution about moving the base file to the root folder) |
Exactly |
Hi everyone,
It would be very helpful if the documentation contained explicit information how to use "SharedResources", i.e. one file (per culture) for all localized strings. It is unclear where to place the files and what to name them, in order for IStringLocalizer (etc.) to find the strings.
I could not figure it out and found my answer here
https://stackoverflow.com/questions/42647384/asp-net-core-localization-with-help-of-sharedresources
but this information should be included in the documentation.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: