Resource File Formats


Before we look into resource managers, let's take a brief look at the possibilities for resource file formats. Four resource file formats are used for resources. The .resx file format that you have already encountered is an XML format. The .resources format that you have also already encountered is a binary format representing a compiled .resx file. The .txt file format is simply a text file with key/value pairs. So Form1Resources.txt would simply be:

 InsufficientFunds=Insufficient funds for the transfer 


The .restext file format (introduced in the .NET Framework 2.0) is the same as the .txt file format; the only difference is the extension. The new extension enables developers to make a clearer distinction between a text file that might contain any freeform text and a text file that is used explicitly for resources. Table 3.1 compares the file formats.

Table 3.1. Resource File Formats

File Extension

Supports String Resources

Supports Other Resources

Supports Comments

Supports File References

Has Direct Support in the .NET Framework

Extension Recognized by ResGen

.resx

Yes

Yes

Yes

Yes

Yes

Yes

.resources

Yes

Yes

No

No

Yes

Yes

.txt

Yes

No

No

No

No

Yes

.restext

Yes

No

No

No

No

In 2.0 only


When choosing a file format, weigh the relative benefits of each. .resx files are recognized by Visual Studio and are human readable. They also have explicit classes for their manipulation (ResourceManager, ResXResourceReader, ResXResourceWriter). .resources files are not human readable and must originate from a .resx, .txt, or .restext file. .txt files are human readable but are not recognized as resource files by Visual Studio, and are not so easily manipulated programmatically as resources.




.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