lundi 1 décembre 2014

Resource translation in custom WebPart failure



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.GetLocalized("searchWelcomeMsg"));


Following is GetLocalized code:



public string GetLocalized(string strId)
{
return SPUtility.GetLocalizedString("$Resources:" + strId, _resxName, _currentLang);
}


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.








0 commentaires:

Enregistrer un commentaire