Skip to content

Extractor: how to add context to POFile #3

@nkosi23

Description

@nkosi23

Hello,

Thank you again for this neat project! When I used the (much more limited) po implementation from the Orchard project, one thing I found very practical was that the message context of every translatable string was the source code surrounding the call to the translation component. For example, if a source file contained:

<div>
    <h1 class="display-4">@T["Welcome"]</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

The resulting po file would contain something like:

#| msgctxt "<h1 class="display-4">@T["Welcome"]</h1>"
#| msgid "Welcome"
msgid "Welcome"
msgstr "Bienvenue"

And if I remember correctly it even contained the preceding line and the next line. This additional context is most of the time very useful to determine what would be the best translation in a foreign language.

Could you please point me to the place that I would need to modify in the source code to have a similar behavior? Right now, the message context is set to the path of the file which is much less useful. Another problem is that an absolute path is specific to the computer of the developer running the extractor tool, therefore this would not play well in a team context if several developers need to add translatable strings. For many reasons, setting the context to the source code seems to be the way to go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions