Groups | Blog | Home
all groups > dotnet internationalization > january 2006 >

dotnet internationalization : Localizing winforms in Vs2003 - Can anyone give simple understandable instructions?


Bob
1/28/2006 12:20:38 PM
I have a project SGIIMSTransCalls - I created a resource file resources.resx
under the project folder. I then created a second resource file called
ressources.fr.resx. As I go along when I need a special message I create it
in the resource.resx file and translate it with the same name in the
resources.fr.resx file. I know its all supposed to end up as a satelite
assembly under each one's own folder under bin. I've been reading the damn
doc for three days and all it does is refer you from one link to another
with nothing saying step 1 step 2 step 3 and you're done. The samples in the
sdk for dot net v1.1 are totally useless.

Can someone PLEASE give a clear series of steps on how to proceed from
situation above to have the application pick up the localized message
strings or tell me what I'm doing wrong. I know I'm stupid, I've been trying
to get my head around this localization stuff with satellite assemblies for
literally months and I keep getting messages like
An unhandled exception of type
'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the
specified culture (or the neutral culture) in the given assembly. Make sure
"SGIIMSTransCalls.resources" was correctly embedded or linked into assembly
"SGIIMSTransCalls".
baseName: SGIIMSTransCalls locationInfo: <null> resource file name:
SGIIMSTransCalls.resources assembly: SGIIMSTransCalls,
Version=1.0.2218.29299, Culture=neutral, PublicKeyToken=null.

I don't want my ressource assemblies in the GAC. I just want them in their
own folder under the bin folder
When I look into my bin/en and bin/fr folders, they get created but there is
nothing in it. If the build process knows to build the folders for the two
localization files isn't it supposed to be smart enough to create these and
put them in there? It looks as it's as dumb as me, but its smart enough to
put localized properties of controls in the localized dlls. Whem I switch
locales, my french interface comes up OK, all I need is the damn message box
messages that I create to do the same.

My code for getting the strings is
Public Function getressourcestring() as string
Dim rm As New ResourceManager("SGIIMSTransCalls",
[Assembly].GetExecutingAssembly())
I tried the above line with "resources" with an empty string, nothing works
' Get the culture of the currently executing thread.
' The value of ci will determine the culture of
' the resources that the resource manager retrieves.
Dim ci As CultureInfo = Thread.CurrentThread.CurrentCulture
' Retrieve the value of the string resource named
' RessourcNameString localized for the culture specified by ci.
Return rm.GetString(RessourcNameString, ci) 'This is the line
that returns the aboveerror message.
end function
..

Please guys and galls, (I'm not sexist, too old for that anyways), Can
anyone help me here?

Thanks for bearing with me.

Bob



marinm NO[at]SPAM online.microsoft.com
2/2/2006 12:13:03 AM
Hi Bob,
When you call the resource manager in 2003, you need to specify the fully
qualified name of the resource. In your case, the name should be the
default namespace, which is the project name (SGIIMSTransCalls), + the name
of the resource file(resources). So your code would look like:
Dim rm As New ResourceManager("SGIIMSTransCalls.resources",
[Assembly].GetExecutingAssembly())

The file that gets embedded in the assembly manifest would be called.
"SGIIMSTransCalls.resources.resources", since the ".resources" always gets
tacked onto the end of the binary resource file to identify it as a
resource file.

I have a few comments on the code below.

Dim ci As CultureInfo = Thread.CurrentThread.CurrentCulture '[marin]
Resources are loaded according to the UI culture so the call should be Dim
ci As CultureInfo = Thread.CurrentThread.CurrentUICulture. However, this
is only necessary if you want to override the OS UI language.
CurrentCulture will be the value set in the Control Panel, Regional Options
for Standards and Formats.

' Retrieve the value of the string resource named
' RessourcNameString localized for the culture specified by ci.
Return rm.GetString(RessourcNameString, ci) 'This is the line
'[marin] see above. The ResourceManager will load according to the
CurrentUICulture, you only need to specify this if you want to override the
default

Hope this helps,
Marin Millar [MSFT]


AddThis Social Bookmark Button