localization of Custom Fields names

Topics: Localization
Feb 29, 2012 at 10:13 AM
Edited Mar 2, 2012 at 5:34 PM

Hello everyone,

I tried to look for similar issue I'm having, and since I didn't find any I would appreciate your help answering my question or directing me to the right place.

I'm using the Culture picker module for localization.

Many Content Items of the website are based on a custom "Content Type" that I've created. This content type is composed of many fields of type:  TextField, DateTimeField and HtmlField.

My Question: is there a way to create localization for the names of these custom fields. I know that they exist in XML format in the databse, in the table: "Orchard_Framework_ContentItemRecord"

XML in Orchard_Framework_ContentItemRecord

<Data>
  <MyCustomContentType>
    <MyCustomField1> data </MyCustomField1>
    <MyCustomField2> date </MyCustomField2>
    <MyCustomField3> date </MyCustomField3>
    ...
  </MyCustomContentType>
</Data>


I would like to translate: MyCustomField1, MyCustomField2, etc ... to more than 1 language.

Thank you for your help

Mar 2, 2012 at 4:37 AM

In Orchard 1.4, I can see that the XML are is migrated to the table: "Orchard_Framework_ContentItemVersionRecord"

same question though, is there are a solution already available to translate the Custom Fields (XML)

Coordinator
Mar 2, 2012 at 5:01 PM

If you want to localize field names, you will need to use .po files. If you want to localize content, it should work the same as with the rest of the content items.

Mar 2, 2012 at 5:16 PM
Edited Mar 2, 2012 at 5:30 PM

Specifically, I would like to localize the "DisplayName" of the custom field, which is stored in the "Orchard_Framework_ContentItemVersionRecord" table.

 


ex, I added custom field Price to my Content Type, which is saved in the "Orchard_Framework_ContentItemVersionRecord" table as:

<settings DisplayName="Price" NumericFieldSettings.Required="False" 
NumericFieldSettings.Scale="0" NumericFieldSettings.Minimum=""
NumericFieldSettings.Maximum="" />

Mar 2, 2012 at 5:49 PM

Correction regarding Orchard 1.4 comment above. It looks like the architecture has completely changed, and custom fields in the ContentItem are not anymore stored in XML format, in one table. Instead, custom fields values of a ContentItem is spread out in the Projections tables, and the settings of those fields are stored in the "Orchard_Framework_ContentItemVersionRecord" table.

Coordinator
Mar 2, 2012 at 6:24 PM

They are still stored in XML in the content item version record (for localization purpose). But the Projector module is also creating some indexes based on their values to be able to query them only.

Also I have just checked the code and the display names are not localizable right now. You might want to file a bug for that. A temporary solution is to duplicate the field templates in your theme and call @T(name) instead just of @name.

Mar 2, 2012 at 7:10 PM

Thanks a lot Sebastien for your input. I will file a bug as you said. Also, thanks for the hint on how to create a temporary solution for the moment.

Mar 29, 2012 at 4:48 AM
Edited Mar 29, 2012 at 4:51 AM

Hello

I had similar issue to phusion. I want to localize a string that get dynamically from database , ex: T(item.Status) , but it seem doesn't work because the status string does not appear in the .po file. I have read somewhere on the forum that the it will look for all instance of localizer in the format  T("....") only ,and the T(item.status) will not be counted as a localization string. Any help plz.

 

Thanks

Developer
Apr 22, 2012 at 11:35 AM

Yes, since that is a variable the localization extractor tool can't extract it. You could add it to your .po file manually, using the string that would be normally output as an id.

Oct 21, 2012 at 5:21 PM

I have run into the problem of the Display Name not being localized.  I have come across this when displaying the field name in an error message, the field name is not localized, but the error message format is.  I couldn't find a raised bug for this, so I created one http://orchard.codeplex.com/workitem/19173

Oct 23, 2012 at 1:32 PM
Edited Oct 23, 2012 at 1:44 PM

I was able to get over this issue by using the .po file as Sebastien and Piedon suggested. But then later I re-created everything in a module (instead of using the administration UI to create the content item) where the display name will actually be a column name in a table. That is the way it should be done in the first place because this is when I really discovered how powerful and extensible Orchard is.

However, it looks like it is still an issue if you want use the admin section. I filed a bug for it at the time (Orchard 1.4).

Jan 26, 2014 at 12:09 PM
I duplicated the field templates in TheAdmin theme and call @T(name) instead just of @name. But how can i limit localization for special module in this case?
For example if i add translation for "Delay" in admin .po file this translates this word for all modules. How can i reference to my module from theme .po file?