How to: Localize Menu Commands
You can provide localized text for menu and toolbar commands by creating localized .vsct files and localized .resx files for your VSPackage, and then updating the project files to incorporate the changes.
For information about how to localize the installation experience, see Localizing VSIX Packages.
In VSPackages, menu commands and toolbar buttons are defined in the .vsct file.
To create localized menu commands
In Solution Explorer, change the name of the .vsct file from filename.vsct to filename.en-US.vsct.
Make a copy of filename.en-US.vsct for each localized language.
Name each copy filename.Locale.vsct, where Locale is a particular culture name. For a list of culture name values, see National Language Support (NLS) API Reference on the MSDN Web site.
These filename.Locale.vsct files will contain the localized menu text for your package.
Open each filename.Locale.vsct file to localize the text.
Modify the ButtonText element values as appropriate for the particular language.
If you will provide localized icons, modify the Bitmap values to point to the target files.
The following example shows English and Spanish button text for a command to open a Family Tree Explorer tool window.
<Button guid="guidLocalizedPackageCmdSet" id="cmdidFamilyTree" priority="0x0100" type="Button"> <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/> <Icon guid="guidImages" id="bmpPic2" /> <Strings> <CommandName>cmdidFamilyTree</CommandName> <ButtonText>Family Tree Explorer</ButtonText> </Strings> </Button>
<Button guid="guidLocalizedPackageCmdSet" id="cmdidFamilyTree" priority="0x0100" type="Button"> <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/> <Icon guid="guidImages" id="bmpPic2" /> <Strings> <CommandName>cmdidFamilyTree</CommandName> <ButtonText>Explorar Arboles de Familias</ButtonText> </Strings> </Button>
Text resources other than command names are defined in resource (.resx) files.
To create localized resource files
Rename VSPackage.resx to VSPackage.en-US.resx.
Make a copy of the VSPackage.en-US.resx file for each localized language.
Name each copy VSPackage.Locale.resx, where Locale is a particular culture name.
Rename Resources.resx to Resources.en-US.resx.
Make a copy of the Resources.en-US.resx file for each localized language.
Name each copy Resources.Locale.resx, where Locale is a particular culture name.
Open each .resx file to modify the string values as appropriate for the particular language and culture. The following example shows the localized resource definition for the title bar of a tool window.
You must modify the assemblyinfo.cs file and the project file to incorporate the localized resources.
To incorporate the localized resources into the project
From the Properties node in Solution Explorer, open assemblyinfo.cs or assemblyinfo.vb in the editor.
Add the following entry.
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
This sets US English as the default language.
Unload the project.
Open the project file in the editor.
Locate the ItemGroup element that contains EmbeddedResource elements.
In the EmbeddedResource element that calls VSPackage.en-US.resx, replace the ManifestResourceName element with a LogicalName element, set to VSPackage.en-US.Resources, as follows.
For each localized language, copy the EmbeddedResource element for VsPackage.en-US, and set the Include attribute and LogicalName element of the copy to the target locale, as shown in the following example.
To each localized VSCTCompile element, add a ResourceName element that points to Menus.ctmenu, as shown in the following example.
Save the project file and reload the project.
Build the project.
This creates a main assembly, and resource assemblies for each language. For information on localizing the deployment process, see Localizing VSIX Packages