OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Wrong msgctx calculated in PortableObjectStringLocalizerFactory

Open skyflyer opened this issue 4 months ago • 3 comments

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

  1. Clone a simple demo project that uses the PO localization: e.g.: https://github.com/skyflyer/DotnetPoLocalizationDemo
  2. Add the project name before the Views in the msgctxt in the localization file
  3. Run the project
  4. See that the string is not localized, because the calculated msgctxt for 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

skyflyer avatar Aug 24 '25 09:08 skyflyer

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.

github-actions[bot] avatar Aug 24 '25 09:08 github-actions[bot]

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

hishamco avatar Aug 24 '25 18:08 hishamco

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.

github-actions[bot] avatar Aug 28 '25 17:08 github-actions[bot]