Some resources of my project aren't translated properly. Wanted behavior is resource displayed in both French and English. Default site's language is English.

When I force my web browser to display content in French it works fine:

French translation

but in English it fails:

English translation

What is wrong with my code?

CustomWebPartManager manager = new CustomWebPartManager("MSContentEditor.dwp", web);
manager.AddWebPartToPage(welcomePageUrl, "MainZone", 0);
manager.SetWebPartPropertyXml("Content", resM.GetFullResID("searchWelcomeMsg"));

Following is GetFullResID code:

public string GetFullResID(string strId)
        return "$Resources:" + _resxName + "," + strId;

All resources files are deployed (XXXX-SearchCenter.en-US.resx and XXXX-SearchCenter.fr-fr.resx).

Translation only fails in this custom web part and in a custom menu node definition.

Thank you in advance for any help!

  • Just to be sure, have you checked that the files actually contain the resource keys you are using? If the resource file is the same for bot the search field watermark and the search field label, only possible explanation that comes to mind is that the system doesn't find the key for the label. – Hitodama Dec 1 '14 at 15:46
  • Yes. When I use SPUtility.GetLocalizedString it is displayed in English but... in both French and English version – Othella Dec 1 '14 at 15:52

I ended up creating a custom WebPart with a ASP Label conponent which text is set to SPUtility.GetLocalizedString("XXX")

using (SPLimitedWebPartManager wpManager = web.GetLimitedWebPartManager(welcomePageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
                        WPSearchWelcomeMessage webpart = new WPSearchWelcomeMessage();
                        wpManager.AddWebPart(webpart, "MainZone", 0);


public partial class WPSearchWelcomeMessage : WebPart
    public WPSearchWelcomeMessage()
        base.ChromeType = PartChromeType.None;

    protected override void OnInit(EventArgs e)

    protected void Page_Load(object sender, EventArgs e)
        ResourceManager resM = new ResourceManager("XXX-SearchCenter");
        SearchWelcomeMessage.Text = resM.GetLocalized("searchWelcomeMsg");

where SearchWelcomeMessage is a Label

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.