0

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?

0

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);
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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