Skip to content

Wrong msgctx calculated in PortableObjectStringLocalizerFactory #18283

@skyflyer

Description

@skyflyer

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions