There are two options for providing a localized experience for your library package:
Different libraries have different localization requirements, so it's important to consider the differences between these two approaches.
Usually the simplest approach for localization is to include all of the localized satellite assemblies and XML IntelliSense in the same package as your runtime. Here's an example package layout that accomplishes this.
SuperAwesomeness.1.0.0.nupkg
Language: en-us
lib └───net40 │ SuperAwesomeness.dll │ SuperAwesomeness.xml │ ├───de │ SuperAwesomeness.resources.dll │ SuperAwesomeness.xml │ ├───it │ SuperAwesomeness.resources.dll │ SuperAwesomeness.xml │ ├───ja │ SuperAwesomeness.resources.dll │ SuperAwesomeness.xml │ ├───ru │ SuperAwesomeness.resources.dll │ SuperAwesomeness.xml │ ├───zh-Hans │ SuperAwesomeness.resources.dll │ SuperAwesomeness.xml │ └───zh-Hant SuperAwesomeness.resources.dll SuperAwesomeness.xml
This package contains a single class library (SuperAwesomeness.dll) that contains the English strings as part of the runtime assembly. The package also contains localized satellite assemblies and XML IntelliSense files for German, Italian, Japanese, Russian, Chinese (Simplified) and Chinese (Traditional).
Installing this package into your project will yield a fully localized experience in any of the languages it supports.
There are a few disadvantages to bundling your localized files into your runtime package.
As of version 5.4.0 The Microsoft.Data.OData package utilizes the single package approach.
The satellite package approach allows you to separate your localized resources from your runtime assemblies, much like the .NET Framework supports satellite assemblies. Here is a sample package structure that includes all of the packages involved.
SuperAwesomeness.1.0.0.nupkg
Language: en-us
lib └───net40 SuperAwesomeness.dll SuperAwesomeness.xml
SuperAwesomeness.de.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───de SuperAwesomeness.resources.dll SuperAwesomeness.xml
SuperAwesomeness.it.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───it SuperAwesomeness.resources.dll SuperAwesomeness.xml
SuperAwesomeness.ja.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───ja SuperAwesomeness.resources.dll SuperAwesomeness.xml
SuperAwesomeness.ru.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───ru SuperAwesomeness.resources.dll SuperAwesomeness.xml
SuperAwesomeness.zh-Hans.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───zh-Hans SuperAwesomeness.resources.dll SuperAwesomeness.xml
SuperAwesomeness.zh-Hant.1.0.0.nupkg
Dependency: SuperAwesomeness [1.0.0]
lib └───net40 └───zh-Hant SuperAwesomeness.resources.dll SuperAwesomeness.xml
If a developer installs this full set of packages, the same fully localized experience will be accomplished as the Single Package Approach. The satellite assemblies and localized IntelliSense will be utilized.
The satellite package approach offers the following benefits:
However, satellite packages have their own set of disadvantages:
Satellite packages work by way of a strict set of conventions. Aside from these conventions, satellite packages are no different from any other NuGet package. In order for the package to be treated as a satellite package though, all of the conventions must be followed.
By following these conventions, NuGet recognizes that the package is a satellite package at the time of installation. When that is identified, the localized files in the lib folder are copied into the runtime package's lib folder at the time of package installation. When the satellite package is uninstalled, the localized files are removed from the runtime package's lib folder. Once the localized files are copied into the runtime package's lib folder, Visual Studio and MSBuild do the rest of the work.
ASP.NET MVC package is one example that utilizes the satellite package approach. Here are some of the related packages: