18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.NET APPLICATION PROGRAMMING INTERFACE<br />

into satellite assemblies (using the naming convention .resources.dll) and placed in subdirectories of the main build directory.<br />

The subdirectories are named after the culture of the satellite assembly they<br />

contain. For example, Swiss–French resources would be contained in a fr-CH<br />

subdirectory.<br />

When an application runs, it automatically uses the resources contained in the<br />

satellite assembly with the appropriate culture. The appropriate culture is determined<br />

from the Windows settings. If a satellite assembly for the appropriate<br />

culture cannot be found, the default resources (those embedded in the main<br />

assembly) will be used instead.<br />

The following sections give more information on creating your own .resx and<br />

.resources files.<br />

Embedding a default .resources file in your project<br />

1. Right-click the project name in the Solution Explorer, click Add, then click<br />

Add Existing Item to navigate to your .resx or .resources file.<br />

2. In the Solution Explorer, choose the file you just added and press F4 to<br />

display its properties.<br />

3. Set the Build Action property to Embedded Resource.<br />

This will ensure that your application always has a set of resources to fall back<br />

on if there isn’t a resource DLL for the culture your application runs in.<br />

The Visual Basic .NET and C# flavors of the Pan<br />

Tool developer sample illustrate how to localize<br />

resources for German language environments.<br />

The sample can be found in the <strong>Developer</strong><br />

Samples\ArcMap\Commands and Tools\Pan Tool<br />

folder. Strictly speaking, the sample only requires<br />

localized strings, but the images have been<br />

changed for the “de” culture as well, to serve as<br />

illustration.<br />

Creating .resources.dll files for cultures supported by your project<br />

1. First, ensure you have a default .resx or .resources file in your project.<br />

2. Take the default .resx or .resources file and create a separate localized file for<br />

each culture you want to support.<br />

• Each file should contain resources with the same Names; the Value of each<br />

resource in the file should contain the localized value.<br />

• Localized resource files should be named according to their culture, for<br />

example, ..resx or<br />

..resources.<br />

3. Add the new resource files to the project, ensuring each one has its Build<br />

Action set to Embedded Resource.<br />

4. Build the project.<br />

The compiler and linker will create a separate satellite assembly for each<br />

culture. The satellite assemblies will be placed in subdirectories under the<br />

directory holding your main assembly. The subdirectories will be named by<br />

culture, allowing the .NET runtime to locate the resources appropriate to the<br />

culture in which the application runs.<br />

The main (default) resources file will be embedded in the main assembly.<br />

A batch file named buildResources.bat has been<br />

provided in the Pan Tool sample to create the<br />

default .resources files and the culture-specific<br />

satellite assemblies.<br />

Chapter 4 • <strong>Developer</strong> environments • 165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!