February 21, 2006
My.Resources and Localization
Let's say you want to localize an application. You can set the localizable property of your forms, but if you have other strings that need to be localized (the text of messageboxes, for example), you will also need a way to obtain a localized string at run-time.
My.Resources supports this. Just follow these steps:
1. Create a new VB.NET Windows Forms project.
2. Double-click My Project in the solution explorer.
3. Click the Resources tab.
4. Set the Name for the first resource entry to Message1.
5. Set the Value to This is English
6. Right-click on the project in the Solution Explorer, and select Add | New Item.
7. For the item template, select Resource File.
8. Set the name to Resources.es.resx, and click Add.
9. In the resource editor, set the Name for the first resource entry to Message1.
10. Set the Value to This is Spanish
11. In the Solution Explorer, double-click Form1.
12. Add two buttons to Form1.
13. In the click event for the first button, enter:
14. In the click event for the second button, enter:
15. Run the application. When you click the first button, you will see the English resource string. When you click the second button, you will see the Spanish resource string.
Posted on February 21, 2006 at 09:14 AM | Permalink
Exceptional, I've been looking all around for such a simple solution. Everyone speaks of manually generating resource files etc. This is simple, clean and scalable.
Posted by: Georgios Kasselakis | Jul 23, 2008 12:31:46 PM
It's one thing to complain about something that's lacking the a product, but Bill is actually someone who will step up
Posted by: pandora jewelry | Dec 13, 2010 5:28:11 AM
The comments to this entry are closed.