This project is read-only.

Localize custom field view in theme

Topics: Writing themes
Jan 12, 2012 at 10:02 AM

In a custom theme "TestTheme", I'm trying to make a custom template for displaying a new content type "Article". This content type have some custom fields (TextFields and HtmlFields) added.

A TextField field in the "Article" called "CommonName" have a custom view/alternate, called "Fields.Common.Text-Article-CommonName.cshtml", displaying correctly. It looks like this:

@if (HasText(Model.Value)) { <span class="article-common"> @Model.Value @T("Common name") </span> }

And in a folder called TestTheme/App_Data/Localization/{lang}/orchard.theme.po there is a translation for the custom view:

#: ~/Themes/TestTheme/Views/Fields.Common.Text-Article-CommonName.cshtml
#| msgid "Common name"
msgctx "~/Themes/TestTheme/Views/Fields.Common.Text-Article-CommonName.cshtml"
msgid "Common name"
msgstr "Common name (translated)"

However, the translation when making an alternate like this seems to be ignored. I saw there was a discussion for a similiar issue when doing the same from modules (, but I couldn't find anything on the specific issue.

The above is just an example - ofc. {lang} is a correct culture. 
I've tried all sorts of things. The po-file is correct (tried making values for the layout-file for the theme, it worked perfectly). Setting the path to the ~/Core/Common/Views/Fields.Common.Text.cshtml doesn't work. I've noticed there is slightly different ways of writing the syntax for the .po-files (some doesn't have "msgctx", Vandelays translation tool is writing "msgctxt" (with an additional "t") and no " around the msgctx(t) value etc.) - I tried all combinations.

Is it a wrong approach or a bug? (Or just a stupid mistake from my side?)

Feb 3, 2012 at 10:06 PM

Please file a bug in the issue tracker.

Then again, the correct syntaxt is "msgctxt" according to the po file spec. There is a bug on the web site, that I will fix.

Feb 4, 2012 at 1:43 AM

The site is fixed and should now serve files with "msgctxt".