When you declare a SPField in CAML, you can add the localization in the code:

  Group="MyProject Columns"

However, some of the fields have to be created in code (e.g. External Data Columns). For these I also want localization. I found this solution, but I wonder if there's a cleaner way to do this.


You can add fields programmatically using list.Fields.AddFieldAsXml, providing CAML field definition with resource tokens in it.

Or you can wrap SetValueForUICulture in a nice helper method, and gain a capability to use it for any SPUserResource object. We're using this approach at work, and I would not say, that it is unclear or smth like this :) It's ok, just wrap it.

| improve this answer | |
  • I tried with the AddFieldAsXml. The field takes the localization on list creation, however when changing language, it doesn't change (all other fields do). – Bart Oct 13 '11 at 15:08
  • Yep, a harsh detail. Haven't known about this. But what I do know undoubtedly, is that SetValueForUICulture will work properly with on-fly localization. – Andrey Markeev Oct 13 '11 at 19:50

Have a look at SPUtility.GetLocalizedString()

| improve this answer | |
  • I still got to push the localized string in some property, since I want the localization to change when the user changes his language in the browser, not only on provisioning. – Bart Oct 13 '11 at 7:23
  • Gotcha. Go for omlin's answer. – James Love Oct 13 '11 at 7:27

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.