Saturday, May 23, 2009

Localization of web parts in SharePoint

My colleague Sanjaya has posted a fantastic article on localizing SharePoint web sites and web parts.

One of the major problem when comes to localizing web parts is that you have to have all translations relates to the locale you are using, if you are to build the embedded resources.

So I would prefer let the customer do the translations rather than we do it.In that case if you can send the set of resources files ( *.resx ) to the customer he can easily open those files and he can do the translation as he needs.

What my colleague mentioned in his article is totally alright but it is not entirely to my likings when comes to localizing web parts because of the above mentioned reason.

So I just used the resources files (*.resx) but not deployed them as embedded resources.

How to do it ?

  • Add the relevant resource files in to your web part.
  • Use the following fragment of code to access the resource strings from the resource files as required in your controls.
  • HttpContext.GetGlobalResourceObject("<resource file name>", "<resource key>").toString()
  • Make sure to have the resource files in the “App_GlobalResources” directory of the corresponding web application project.

More can be read from the following references :

http://tomblog.insomniacminds.com/2008/02/25/sharepoint-internals-resources/

http://www.mikhaildikov.com/2007/03/sharepoint-resources-types-use-and_2163.html

No comments: