A quick and easy way to localize strings in a display template is to simply write out the translated values in the page. This way, you don't have to use separate resource files for the client side (e.g. like http://ift.tt/1jLcHKF).
Step 1: Write out the current resource string to a JavaScript variable in the page
string script = String.Format("var rsMyResource = '{0}';", ResourceService.GetLocalizedString("MyResource"));
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "rsTS", script, true);
Step 2: Insert the varaible in the display template
<span class="srLink"><a href="_#=openUrl=#_">_#=rsMyResource=#_</a></span>
Of course, this is not recommend for a large number of resources.
Get more infos like this daily: http://ift.tt/1SAPJaw
by Oliver Pistor via Everyone's Blog Posts - SharePoint Community
No comments:
Post a Comment