Wrong msgctx calculated in PortableObjectStringLocalizerFactory
Describe the bug
The PortableObjectStringLocalizerFactory which is responsible for calculating the msgctxt has a bug, where the project name is removed. This works fine in the Orchard CMS codebase, because the projects/areas are nested in a specific way, but breaks for generic projects.
Orchard Core version
latest, 2.1.7, probably others as well
To Reproduce
- Clone a simple demo project that uses the PO localization: e.g.: https://github.com/skyflyer/DotnetPoLocalizationDemo
- Add the project name before the
Viewsin the msgctxt in the localization file - Run the project
- See that the string is not localized, because the calculated
msgctxtfor the translation is without the project name
Expected behavior
The msgctx should include the project name.
Discussion
At first, I thought that the issue is with the PO Extractor tool, but after some tinkering and thinking about it, I believe the tools works correctly and that the PortableObjectStringLocalizerFactory is incorrectly calculating the context. This, interestingly, works correctly in the Orchard CMS codebase, because of how the projects are nested.
There is some more analysis in the PR which I filed for PO Extractor tool (which I believe is the wrong fix for this issue, as that would also break the Orchard CMS localization).
- https://github.com/OrchardCoreContrib/OrchardCoreContrib.PoExtractor/pull/109
- another related issue: https://github.com/OrchardCMS/OrchardCore/issues/5263
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.
IMHO, the discussion should go into https://github.com/OrchardCoreContrib/OrchardCoreContrib.PoExtractor repo. Moreover, you could prepare your sample and demo it at the upcoming OC meeting on Tuesday. I hope I can join you; otherwise, I'm sure that @sebastienros will let you know if you have any confusion, or he will confirm if there's a bug
I will reply to your related PR on the related repo
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.