Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

according to the documentation I can do:

<ContentTypeID="0x01000188a30d01ae4607bbe5800bbbaf2550"
           Name="$Resources:LocalizeContentType,ContentTypeTitle" 
           ....

However I seem to be unable to do:

var contentType = new ContentType(parent, web.ContentTypes, "$Resources:LocalizeContentType,ContentTypeTitle"); 

The error being that a name of a contentType can not contain characters like "$" and so on...

How can I create a ContentType (in code) whose name is localized?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You should use SPUtility to retrieve content type name and use this name like this:

string str = "$Resources:key";
string locStr = SPUtility.GetLocalizedString(str, "resource_file", (uint)culture.LCID);
var contentType = new ContentType(parent, web.ContentTypes, locStr);
share|improve this answer
    
Thanks, that's what I'm doing now. Having read the declarive way I was somehow stuck in trying the same in code. ;-) –  Nils Oct 12 '12 at 16:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.