Localizing your VS package resources

I had this question come to my inbox today:

Can someone confirm how to setup your VSIP Package for multiple languages?

I did a little digging and realized that the docs are vague on exactly how this works. The EnvSDK samples show you what to do, but there's little explanation about how VS tries to locate the appropriate satellite dll. So, here is how this works:

First you install your satellite dll into a path with the LCID representing the locale for which the dll has been localized. So, for the English (US) local you install to a path like this c:\....\1033\<Your English satellite dll file>. Other locales would use a different LCID. For Spanish, you would do something like this: c:\....\1044\<Your Spanish satellite dll file>. It is important that the file be named the same for all locales.

Each package registers itself in the VS registry hive. In the package registration information is a key for SatelliteDll that provides a value for the Path and a value for the DllName. Like this:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1Exp\Packages\{YOUR-PACKAGE-GUID-HERE}\SatelliteDll]
"Path"="<Path to your satellite dll w/o specifying the LCID>"
"DllName"="<Your satellite dll file name>"

When VS needs to get resources out of the satellite dll, it looks at the Path value, adds the LCID for the appropriate locale and loads the satellite dll. VS chooses the LCID based on the following list (in order to preference):

1) Language specified in Tool/Options/../IntlSettings

2) Same as #1, but with SUBLANG_DEFAULT

3) The UI language as returned by GetUserDefaultUILanguage from the OS

4) Same as #3, but with SUBLANG_DEFAULT

5) English (1033)

6) Any language that can be found

To access the resources in your own code the package can use the IVsShell interfaces proffered by the SVsShell service. IVsShell::LoadPackageString can be used to load a string resource from the satellite dll. IVsShell::LoadUILibrary can be used to get the HINSTANCE of the dll so you can use Win32 resource related API's to load all types of resources.

I hope this helps.

Allen