.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
To reap the rewards of our work, we need to offer a second or third language. In this example, we add French to the list of supported languages. This is where the culture strings that we discussed earlier come in. The culture string for neutral French is "fr." Create a new Resource File using the same name as before, but use a suffix of ".fr.resx" instead of just ".resx" so that the complete filename is Form1Resources.fr.resx. Into this resource file, add a new string, using the same name as before, "InsufficientFunds"; into the Value field this time, though, type the French equivalent of "Insufficient funds for the transfer" (i.e., "Fonds insuffisants pour le transfert"). Compile the application and inspect the output folder. You will find a new folder called "fr" beneath the output folder. If the output folder is \WindowsApplication1\bin\Debug, you will find WindowsApplication1\bin\Debug\fr. In this folder you will find a new assembly with the same name as the application, but with the extension ".resources.dll" (i.e., WindowsApplication1.resources.dll). The Form1Resources.fr.resx file has been compiled and embedded in this new assembly. This new assembly is a resources assembly, and it contains resources only. This assembly is referred to as a satellite assembly. If you inspect the manifest of this satellite assembly using IL DASM (<FrameworkSDK>\bin\ildasm.exe), you will find the following line: .mresource public WindowsApplication1.Form1Resources.fr.resources In this way, you can support any number of languages simply by having sub-folders with the same name as the culture. When you deploy your application, you can include as many or as few of the subfolders as you want. For example, if your application gets downloaded from a Web site or server, you can supply a French version that includes only the French subfolder. Similarly, you can offer an Asian version that includes Chinese, Japanese, and Korean subfolders. In addition, if you update one or more resources, you need to deploy only the updated resource assemblies, not the whole application. |
Категории