Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Internationalization / February 2006

Tip: Looking for answers? Try searching our database.

Localization using text files in VS2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Leftwich - 28 Jan 2006 00:59 GMT
I've created a very simple test app with WinForms to learn how to use
localization in .NET.  The app simply has a button that displays a MessageBox
with a message retrieved from ResourceManager.GetString.  Here's the code:

       private ResourceManager rm =
ProdRegTest.Properties.Resources.ResourceManager;
       private void button2_Click(object sender, EventArgs e)
       {
           string msg = rm.GetString("IDS_MSG");
           MessageBox.Show(msg);
       }

I added a text file resource to my project in the project properties dialog,
then entered a single line like the following:

IDS_MSG = Hello world

When I run the program, the message box is displayed with a null string
instead of "Hello world".

I have verified that VS creates the .resources file in the obj\debug
directory, and I've looked at the .exe in a hex editor and can see the string
resource embedded in the executable, but for some reason the call to
GetString is returning a null string.

I've tried this now in 2 different projects, with the same result.  I'm sure
I must be doing something really dumb, but I can't see what it might be.

Thanks in advance.

Mike
Michael Höhne - 29 Jan 2006 00:20 GMT
If you're not somehow limited to using text files, please see the discussion
"Localizing non object strings" in this newsgroup. It describes how to use
resource files and localize them in VS.NET 2005, and I guarantee that it
works and is much easier to use.

Michael

Signature

Michael
http://www.stunnware.com/crm
----------------------------------------------------------

> I've created a very simple test app with WinForms to learn how to use
> localization in .NET.  The app simply has a button that displays a
[quoted text clipped - 31 lines]
>
> Mike
Mike Leftwich - 30 Jan 2006 01:00 GMT
I have a strong preference for using text files.  Other modules of this
application are written in Java, and the resource file formats are very
similar.  We plan to share most of the resources to economize on translation
costs.  So I would really like to get the text file method to work if at all
possible.

Thanks for your response!

Mike

> If you're not somehow limited to using text files, please see the discussion
> "Localizing non object strings" in this newsgroup. It describes how to use
[quoted text clipped - 38 lines]
> >
> > Mike
Marin Millar - 02 Feb 2006 20:49 GMT
You can use and compile the text format in VS2005 using some special steps.
Add a new text file, set the file extension to ".restext".  Select the
file in the Solution Explorer, and set the Build Action to Embedded
Resource in the properties window.  
Now you can access the string using the ResourceManager, something like
below:
ResourceManager rm2 = new ResourceManager("LocalizationSample.TextFile1",
Assembly.GetExecutingAssembly());
MessageBox.Show(rm2.GetString("mystring"));
Hope this helps,
Marin Millar [MSFT]
Mike Leftwich - 04 Feb 2006 01:55 GMT
Marin,

Ok, that worked.  But I'm a little baffled as to why it worked.  I tried
doing all the same steps except for changing the file extension, and it's
clear that changing the file extension is required.  It doesn't work if the
extension is .txt.  However, all the help topics refer to naming the file
.txt, and the IDE names it with .txt if you create a new text file in the
resource editor.  In fact, after changing the file extension to .restext the
IDE shows the file with a generic icon and if you try to open the text file
in the resource editor it displays a dialog box that says, "The Managed
Resource Editor does not support the requested file type.  Would you like to
open the default editor for <filename>?"

Am I mistaken in thinking that something is broken here?

Thanks for your help.

Mike

> You can use and compile the text format in VS2005 using some special steps.
>  Add a new text file, set the file extension to ".restext".  Select the
[quoted text clipped - 7 lines]
> Hope this helps,
> Marin Millar [MSFT]

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.