according to the documentation I can do:


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?


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

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.