1

I'm currently localizing a visual web part for the very first time. I'm following this MSDN guide in the first place and I'm a little bit confused about where to place the resource strings or resx-files in my SP2013 project.

Let's say my solution structure looks like this:

enter image description here

From what I've understood so far I could/should use these three different resx-locations:

  • Location A: feature name, feature description, any localized string I want to use during feature activation/deactivation, e.g. error messages or list names
  • Location B: web part title and description, any localized string I want to use in the code behind of the web part
  • Location C: any localized string I want to use elsewhere e.g. in "MyCustomClass.cs"

And to complicate the whole thing, my code should conform to the SharePoint Cop localization rules.

Is it really necessary to use all of the three locations in my case? Or is it possible to safely "combine" some resx-files as some resource strings otherwise would be duplicated?

4

You can create a single global resources file and deploy it to:

{WebApplicationRoot}\App_GlobalResources\

This post shows you more on how to do it: http://blogbaris.blogspot.co.uk/2012/07/localization-with-sharepoint-2010-and.html

The post is based on SP2010 but works just as well for SP2013

  • Thanks. I've forgot to mention in my initial post that the my code should conform to the SharePoint Cop localization rules. Do you know if your approach meets this rules? – jcp Jan 31 '14 at 15:22
  • Sorry, I haven't tried it with SPCop. – Chaholl Jan 31 '14 at 15:27
  • I don't see why Chaholl's method will fail to meet SPCop rules. Anyway, don't trust everything that SPCop says. Sometimes it shows an error where a warning should really be. – Denis Molodtsov Jan 31 '14 at 20:19
1

Resource files in SharePoint are located in different folders, including these:

  • C:\Inetpub\wwwroot\wss\VirtualDirectories\\App_GlobalResources\
  • $SharePointRoot$\14\Resources\
  • $SharePointRoot$\14\CONFIG\Resources\
  • $SharePointRoot$\14\CONFIG\AdminResources\
  • $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\

The target folder you use depends on what kind of resource you want to deploy. Every type of resource has its own.

Provisioning resources are part of either a solution package or a feature. They land in these folders:

  • $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\ Resources..resx
  • $SharePointRoot$\14\TEMPLATE\FEATURES\\Resources\
  • $SharePointRoot$\14\Resources\

Every feature uses the resources file located in its Resources folder. You can, however, use another resource file or even shared resources. To share resource files you have to put them in the 14\Resources\ folder. This is the default option that is used when you add an item of type Global Resource File to your current solution. Site definitions and list definitions also get their resources from this folder. Application resources can appear in these folders:

  • $SharePointRoot$\14\CONFIG\Resources\
  • C:\Inetpub\wwwroot\wss\VirtualDirectories\\App_GlobalResources\

Application resources are located in the CONFIG\Resources folder. For a web application to use those resources, they must be copied to their own App_GlobalResources folder. On creation of the web application, the resources are initially copied to the App_GlobalResources folder. When you add new resources to the CONFIG\Resources folder, the resources need to be copied to existing web applications.

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.