Resource Formats


The strings, bitmaps, icons, audio, and other files that can be translated or localized in your application are collectively called resources. During development, these resources are moved out of the source code and into a separate location. One of the fundamental decisions that you must make is what format these resources will be stored in. This decision has far-reaching implications. The most commonly used format, and the one offered by default in Visual Studio 2003 and 2005, is resx files. A resx file is an XML file. The .NET Framework 2.0 offers resx, resources, txt, and restext as choices, but you can choose a completely new format as well.

A common alternative to these is to use a database to store all resources, but you could equally use XLIFF (XML Localization Interchange File Format, a format used to exchange localization data between tools). As with all decisions, you must weigh the pros and cons. The .NET Framework and Visual Studio lend themselves to using resx files. Their support for this format is complete. resx files can be manipulated using all .NET Framework SDK tools and all parts of Visual Studio, including, notably, Visual Studio's Resource Editor. All other formats have less support to some degree and involve some additional effort to support. This does not mean that a database, for example, cannot be used. In Chapter 12, "Custom Resource Managers," we create a resource manager for a database. In the same chapter, we create a utility for creating strongly typed resources, for resources in any format. In Chapter 10, "Resource Administration," we create a Resource Editor replacement that, among other uses, enables you to read and write resources in any format.

One of the benefits of storing resources in a database is that resources can be changed easily at runtime. (By contrast, unless you are writing an ASP.NET 2.0 application, changes to resx files require a recompilation for the changes to be seen.) Thus, a database offers a great solution for translators because they can immediately see the results of their translation. In addition, a database is suitable if the strings of an application are rapidly changing, making a recompilation of the application unsuitable.




.NET Internationalization(c) The Developer's Guide to Building Global Windows and Web Applications
.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
ISBN: 0321341384
EAN: 2147483647
Year: 2006
Pages: 213

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net