0

I need to make my custom solution for SharePoint 2010 multilingual, I have a Elements.xml file where all my ribbons controls are described but how can in reference to .resx from there and how can i be sure that correct language and culture will be choosed?

2 Answers 2

4

All Sharepoint element.xml modules are localized the same way.

First of all, you need to deploy your resx files into SharePoint Resources mapped folder.

Resources mapped folder

After this, you can use following syntax to reference your localized resources:

$Resources: ResourceFileNameWithoutExtension, ResourceName

Code sample:

<CustomAction
  Id="MyTestCustomAction"
  Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Read">
          <Tab
            Id="Ribbon.Read"
            Title="$Resources:TestResources,MyBrowseTabTitle;"
            Sequence="100"
            Command="ReadTab"
            Description=""
            CssClass="ms-browseTab"
            >
            <Scaling Id="Ribbon.Read.Scaling" />
            <Groups Id="Ribbon.Read.Groups" />
          </Tab>
        </CommandUIDefinition>
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>
1
0

We use a resource helper that wraps SPUtility.GetLocalizedString in code and which can be called with a resource file name, an LCID and of course the resource key. For display purposes yoiu would call this with the current thread's UICulture LCID.

ASPX /ASCX files work differently, they reference resx files stored in the Web apps IIS folder (App_GlobalResources). These can be deployed to the SharePoint root (14-hive) in the config\resources folder. These get deployed to the IIS folder using %STSADM% -o copyappbincontent

Elements.xml can just reference the resources directly i.e. :

Name="$Resources:RESOURCEFILENAME,RESOURCEKEY;"

So, 3 options:

  1. From Code: SPUtility.GetLocalizedString
  2. Regular resource (i.e. elements.xml): Name="$Resources:RESOURCEFILENAME,RESOURCEKEY;"
  3. ASPX / ASCX : App_GlobalResources and %STSADM% -o copyappbincontent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.