Crea un fitxer de recursos utilitzant Visual Studio IDE
Copieu el fitxer de recursos en 12 carpeta de recursos rusc
GetLocalized method from SPUtility to read the values from resource file
Sintaxi:
SPUtility.GetLocalizedString(“$Recursos:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, només);
Exemple:
SPUtility.GetLocalizedString(“$Recursos:MyResources,Nom de pila”, “MyResources”, només);
Exemple de font:
ús System;
ús System.Runtime.InteropServices;
ús System.Web.UI;
ús System.Web.UI.WebControls;
ús System.Web.UI.WebControls.WebParts;
ús System.Xml.Serialization;
ús Microsoft.SharePoint;
ús Microsoft.SharePoint.WebControls;
ús Microsoft.SharePoint.WebPartPages;
ús Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[Guid(“fc643df7-8836-41bf-913f-662ed57e659a”)]
públic
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
cadena Nom de pila;
cadena Cognom;
públic ResourceCollection()
{
}
protected
override
anul · lar CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Recursos:MyResources,Nom de pila”, “MyResources”, només);
LastName = SPUtility.GetLocalizedString(“$Recursos:MyResources,Cognom”, “MyResources”, només);
}
protected
override
anul · lar Render(HtmlTextWriter writer)
{
writer.Write(“Value of First Name from Resource File : “ + Nom de pila);
writer.Write(“Value of Last Name from Resource File : “ + Cognom);
}
}
}
Veri nice article. In my blog I have similar article on how to use SPUtility.GetLocalizedString – http://dotnetfollower.com/wordpress/2011/05/the-usage-of-sputility-getlocalizedstring/