Me vs. VS2003 IDE: Killing my satellites softly

R

Rolf Molini

Hello board,

I just started looking into C# - programming and find it quite applicable for very rapid development scenarios. But the handy
support that the IDE provides has now run me into problems with localization.

I started out very simple with a form called MainForm that is displayed but disabled. This form immediately starts a second form
called "LoginDialog" which contains the usual labels, textBoxes and buttons. It connects to a SQL-Server database to verify login
credentials and - if appliciable - after a couple of seconds closes itself and enables MainForm. The LoginDialog contains a label
which initially contains no text but - after successful login - displays a string like "Welcome" and some user-information fetched
from the database. If the login credentials cannot be verified against the database it shall display a failure message like e.g.
"Wrong username and/or password".

So far all this worked pretty fine and could be created within very short time with the IDE. Then, I started localizing the from and
that's where I encountered a dead-end.

To localize I first used the IDE by making the LoginDialog-form localizable, switching the Language-property of the form and setting
different values to the Text-properties of the elements. I could observe how the IDE created resource-files like e.g.
"MyApp.LoginDialog.resources", "MyApp.LoginDialog.fr.resources" in the project directory, created subdirectories like "fr" and in
there the "MyApp.resources.dll" satellite-assembly. Within the InitializeComponents()-method in the LoginDialog-class the IDE uses
the ResourceManager(type)-constructor to create a Resource Manager of type "LoginDialog". All this works out well.

But now I would need some extra localized variables (e.g. for the Welcome-string or the failure-message mentioned above) which do
not appear as elements within the form. First, I tried to be clever and to add some values to the .resources-files with WinRes.exe.
But every time I touch the form in the designer-view the .resources-file is built anew and my entries are gone. Next, I tried to
build my own .resources-files with the entries for the necessary variables, compile them with Al and place the satellite-assemblies
in the correct subdirectory. But since the names of the files have to follow a strict convention I suppose that my DLLs are
overwritten by the IDE upon building the project (the IDE of course follows this convention).

The question is now: How can I add localized variables to my form which are not elements (controls or components) of the form? Of
course throughout a localized application you need more variables (mostly strings) localized than just the controls or components
within the forms.

Is it the only possibility to set the form in the designer to not localizable (which removes all resp. code from
InitializeComponents), delete the auto-generated .resources and .dll-files, then create my own .resources-files and assemblies, use
my own Resource Manager within InitializeComponent() and manually set the properties of all elements in the form? In this case it
would be very tedious to incorporate all the localized information for the controls (like button-size, -position ...) in my own
assemblies manually. The IDE does a very good job here but it will be useless if I cannot add my own localized variables.

Maybe someone has a clue on how to solve this problem.

Best regards
Rolf
 
R

Rolf Molini

One correction to my former description:

I did not open the IDE-created .resources-files with WinRes or ResEditor (which both will not work on IDE-created .resources-files)
but I edited the .resx-files directly from within the IDE. Upon building these will be overwritten by the IDE based only on the
elements within the form.

Regards
Rolf
 
R

Rolf Molini

Additional information:

I just tried what I described in the first post (setting the form to not localizable and creating a satellite assembly by myself).

But even in this case I can see, that the MyApp.resources.dll in the fr-subdirectory is overwritten by the IDE upon building the
project.



Now I tried the following:

I built the project (resources are aquired by ResourceManager(typeof(LoginDialog)).

Then I used Al to recreate the MyApp.resources.dll in fr-subdirectory from MyApp.LoginDialog.fr.resources. This file contains only
one value I defined myself. In LoginDialog it is set as text-property of one label. I also copied MyApp.resources.dll to the
bin\Debug\fr-directory.

I then manually started MyApp.exe from the bin\Debug-directory, but the self-defined value could not be found, the label had no
text.

Starting MyApp.exe from the obj\Debug-directory was successful: The label had the correct text defined in my .resources-file, all
other elements fell back to the invariant language like they should.


Can anyone explain to me what that means and how I should deal with this?

Thanks
Rolf
 
R

Rolf Molini

Well, still waiting for some answers or questions...



But I can provide for an update:

As described in the other Thread ("Me vs. VS2003 IDE Part 2) I can now (at least symptomatically) explain how the MyApp.exe's in
bin\Debug-directory and obj\Debug-directory differ in behaviour. To cut it short: It is about the MyApp.exe.config-files (for
details see other Thread).


What I have tried regarding the problem of localizing variables of a form which are not controls or components is the following:

Modifying the .resx-files with XML-editor is one way, but it is a very hard restriction that afterwards you are not allowed to
change the language-property of the form to avoid overwriting your own amendments to at least the .resx-file of the currently
selected language.

Regarding localization the documentation suggests that you first finish developing your application an then e.g. pass the neutral
..resx-file to a localizing vendor. If I would follow this path I would develop only in neutral language, then add localized
information by changing the language-property of the form and finally edit the localized .resx-files before building the release.

But I think that it is very hard to figure out a point where you can say: "I will surely never alter any details of my applicaton".
If I follow this path, after providing my own localization information to the .resx-files the application is "shut" and I can never
change or add any elements which are localized because then I would have to change the form's language-property and all my entries
in the various .resx-files would be lost.

Since I found it not applicable to CREATE satellite-assemblies with my own resources (because they are overwritten by IDE at
building the project) I tried to ADD my own resources-information to the IDE-generated satellite-assemblies.

I found that this will work out (at least for all localized languages but not for the neutral language).

AFTER building the project I use "Al /link" instead of "Al /embed" and simply add my self-created .resources-files (they can be
named anything as I found out) to the IDE-generated MyApp.resources.dll's in the various language-subdirectories.

Of course, rebuilding the project will revert the satellite-assemblies to the IDE-generated form but I can always add my part of
resources after building the project this way whenever I like. Thus, the application is never "shut".

I regard this as a very inconvenient way of localizing variables being no control or component within a form but it seems to be the
only one.

Still, I have to figure out how to add localization-values of such variables to the neutral language since for this the IDE does not
use a MyApp.resources.dll (within the project directory) but simply the .resources-files.


Best regards
Rolf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top