-
Notifications
You must be signed in to change notification settings - Fork 37
Msgctxt without project name #109
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
base: main
Are you sure you want to change the base?
Msgctxt without project name #109
Conversation
Make sure your demo contains more than one module that contains at least one shared localization string, then check the generated output |
What do you mean by module? Like another project? |
Exactly, because in Orchard Core, we have a lot of modules and some themes. So, one localization string could be used in many projects that's why the context is handy |
The solution now contains a solution with a Web (MVC) and a Razor Class Library (RCL) which is shared. Food for thought: generate translation template looks like this:
As you can see, the library name is stripped from the views... but this leads me to wonder what would happen if two distinct razor class libraries would have the same view in the same directory and file name? E.g. But, if the |
@hishamco, sure, no problem, but either I am dense or there are no Ok, so after digging about a bit more, there appears to be a https://github.com/OrchardCMS/OrchardCore.Translations project that contains the translations... I've ran it on the OrchardCore repo and there are many changes - most of which are of this type (path separator changes): -#: OrchardCore.AdminMenu\AdminMenu.cs:28
+#: OrchardCore.AdminMenu/AdminMenu.cs:28 Some translations are removed (they don't exist anymore in the source files), which is OK. The -#: OrchardCore.Admin\Views\AdminSettings.Edit.cshtml:24
+#: OrchardCore.Admin/Views/AdminSettings.Edit.cshtml:24
#. <span class="hint">@T["Whether a New menu is displayed in the admin menu."]</span>
-msgctxt "OrchardCore.Admin.Views.AdminSettings.Edit"
+msgctxt "Views.AdminSettings.Edit"
msgid "Whether a New menu is displayed in the admin menu."
msgstr "" Debugging the Why and how it works in the Orchard.Core codebase (where |
Some more Orchard digging... Taking StringLocalizer is created with two arguments:
which leads me to think that the PO localization is sometimes trimming the project name and sometimes not, depending on the project layout. If the project is part of an Area, then the project name is not trimmed (only the parent project is trimmed)... ... which is IMHO inconsistent. What do you think the correct approach should be? IMHO, the localization infra should always leave the project name in place. |
If you download the OC code-base, then run the tool, it will generate all the localization resources, and the message becomes handy when you have the same key available across multiple projects |
@hishamco, perhaps I have worded my comment in way that was not understandable, sorry for that. To summarize:
I will open an issue with the OC repo. I think this PR should be closed, but I'm interested to hear you opinion on the matter, since you seem to be more involved with both projects. |
I commented here for the OC.Translations @agriffard will let you know about all the details, coz he is the one who worked on that. BTW, I need to check this PR one more time, but I need to revise it with a clear mind :) I might defer the release until the weekend or push it ASAP then will decide if there's a new minor or major release if it's required If you want to chat on Discord, feel free to join me there, and thanks for your effort and initiative |
This change adds two unit tests that remove the project name from the and actually removes the project name from the generated context only for Razor metadata.
I created a sample project that this can be tested on: https://github.com/skyflyer/DotnetPoLocalizationDemo
The sample projects includes localization in
.cshtml
as well as localization in.cs
(HomeController), which must preserve the project name (as it is part of the fully qualified class name).