Hello,
I am in the process of writing a tool to automate much of the localization
of a large project. Part of this process has involved localizing message that
are displayed to the user in messageboxes, etc. These messages are stored in
resource files, and they are working for languages that are not our default
language (which is english).
I have run into an issue in getting those messages into the form's default
resource file (if the form were named Form1.vb, the resource file would be
Form1.resx): I am able to edit the form's content using a StreamWriter, but
when I save the changes, the IDE says that the file has been changed and asks
whether to re-load it or not. The catch is, whether you say yes reload it, or
no, it blows away the changes no matter the case.
I notice that if I attempt to edit this resource file using the IDE's
built-in editor, the IDE prompts me about editing it because it belongs to
another project item. If I say that I want to edit it anyhow, it allows me
to. I think the IDE is protecting this file from changes, and I need to get
around that. Can anyone help me? I would rather not have to create a new
resource file to store just english messages when there is a perfectly good
one available when you turn on localization.
Thanks.
sheppe - 10 May 2007 18:15 GMT
I have discovered the solution, though it does involve creating a file
outside of the default resource file. Fortunately, this file is as simple to
use as the default resource file. In the case of a form named Form1, I simply
create a Form1.en.resx file (the same culture as the development platform),
and I store the messages in this file (in well-formed resource file format).
The trick to making this file work properly is to initialize the CultureInfo
object (used when loading resources) with a value of "en" rather than "" when
operating in an english environment. IE:
CultureInfo ci = new CultureInfo("en");
This causes the form to load from the default resource file correctly, as
well as from the .en.resx file.
Cheers.
> Hello,
>
[quoted text clipped - 20 lines]
>
> Thanks.