I need to programmatically add a web part to a page where the title is using a $Resources:Filename,Key; string.

I know I can use SPUtility.GetLocalisedString() to retrieve the correct value (and loop through the SPWeb.SupportedUICultures to set the value for each language) but the problem with that is that it will only set it for languages in use now ... what happens if we install a new language pack next month? (we'd have to loop through all our web part instances and add the new language text for each one... a PITA).

If I was adding a web part in the onet.xml I could just use Title="$Resources:fileName,key;" and it would automatically pick up any translations from available installed RESX files automatically.

How can I do this programmatically? (i.e. in C#)

1 Answer 1


For this situation you can use feature upgrading.

When the new languages are deployed create a new version of the feature in the solution that deployed the WebParts. Upgrade the solution and upgrade the features.

During the upgrade process of the feature you can upgrade the title of the WebPart with the new SPWeb.SupportedUICultures

  • This sounds like a reasonable option. Adding a language pack would be a siginficant change anyway.
    – Russell
    Commented Jan 9, 2014 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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