HighTechTalks DotNet Forums  

Small Problem with Localizing Forms

Dotnet Internationalization microsoft.public.dotnet.internationalization


Discuss Small Problem with Localizing Forms in the Dotnet Internationalization forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Cush
 
Posts: n/a

Default Small Problem with Localizing Forms - 05-03-2006 , 06:33 AM






Hi,
I have a Windows C# app developed using VS2003 and I need to localize it
into German and French.
(I did not create the project) I have come across a few problems and I
would really appreciate any help.

1. The project is made up of Forms and Panels. I notice that if I click on
a panel dialog and view its properties then I get no option to set the
localization to true or to change the language for it. How can I localize a
Panel, I need to do this because the Panel hosts buttons, Labels and Text
boxes.

2. Also I need to localize some of the strings in code. All the examples I
have seen have walked me through the steps where I create 3 .resx files e.g
WinFormStrings.resx (English)
WinFormStrings.de-DE.resx
(German)and
WinFormStrings.fr-FR.resx
(French).

See: http://msdn2.microsoft.com/en-US/library/y99d1cd3.aspx.

When I do this the resource manager does not pull out any of the strings I
enter in the resource files. Have I missed something but if you click 'Show
all files' in the Solution explorer is appears that Visual Studio generates a
..resx file for every Form anyway, so why do we need to add in another one for
English?

Thanks in advance for any help


--------------------------------
From: Ryan Cush

Reply With Quote
  #2  
Old   
Thierry HUGUET [MS]
 
Posts: n/a

Default Re: Small Problem with Localizing Forms - 05-04-2006 , 05:33 AM







2) I remember to have had already this problem. This is because I didn't use
set correctly the parameters on the instruction "new ResourceManager".
It is necessary to mention the namespace name before the resource name
(without extension), and it is case sensitive.

INCORRECT: ResourceManager rm = new ResourceManager("resourcefile",
Assembly.GetExecutingAssembly());
CORRECT: ResourceManager rm = new
ResourceManager("MyNameSpace.resourcefile",
Assembly.GetExecutingAssembly());

Thierry HUGUET
Microsoft France


"Cush" <Cush (AT) discussions (DOT) microsoft.com> a écrit dans le message de news:
D5FEE78F-DF3E-45C7-9A7A-CA9BD987C122...soft (DOT) com...
Quote:
Hi,
I have a Windows C# app developed using VS2003 and I need to localize it
into German and French.
(I did not create the project) I have come across a few problems and I
would really appreciate any help.

1. The project is made up of Forms and Panels. I notice that if I click
on
a panel dialog and view its properties then I get no option to set the
localization to true or to change the language for it. How can I localize
a
Panel, I need to do this because the Panel hosts buttons, Labels and Text
boxes.

2. Also I need to localize some of the strings in code. All the examples
I
have seen have walked me through the steps where I create 3 .resx files
e.g
WinFormStrings.resx (English)

WinFormStrings.de-DE.resx
(German)and

WinFormStrings.fr-FR.resx
(French).

See: http://msdn2.microsoft.com/en-US/library/y99d1cd3.aspx.

When I do this the resource manager does not pull out any of the strings I
enter in the resource files. Have I missed something but if you click
'Show
all files' in the Solution explorer is appears that Visual Studio
generates a
.resx file for every Form anyway, so why do we need to add in another one
for
English?

Thanks in advance for any help


--------------------------------
From: Ryan Cush



Reply With Quote
  #3  
Old   
Cush
 
Posts: n/a

Default Re: Small Problem with Localizing Forms - 05-04-2006 , 06:54 AM



Thanks Thierry that has fixed my problem. I now have a new issue:
Whenever a form is shown for the first time the InitializeComponent() is
called and this is when the resources are pulled from the required .resx
files. My problem is that I have a Treeview component which simply shown and
hides forms in a main dialog depending on what node is selected.(All the
forms are initialised when the program launches of course).
Now if I change the language (using a menu selection) and then simply show
one of the forms it does noe use the new resource strings I want!
Is the only way for a form to use the localized .resx file is to be created
from scratch again?

Thanks.


"Thierry HUGUET [MS]" wrote:

Quote:
2) I remember to have had already this problem. This is because I didn't use
set correctly the parameters on the instruction "new ResourceManager".
It is necessary to mention the namespace name before the resource name
(without extension), and it is case sensitive.

INCORRECT: ResourceManager rm = new ResourceManager("resourcefile",
Assembly.GetExecutingAssembly());
CORRECT: ResourceManager rm = new
ResourceManager("MyNameSpace.resourcefile",
Assembly.GetExecutingAssembly());

Thierry HUGUET
Microsoft France


"Cush" <Cush (AT) discussions (DOT) microsoft.com> a écrit dans le message de news:
D5FEE78F-DF3E-45C7-9A7A-CA9BD987C122...soft (DOT) com...
Hi,
I have a Windows C# app developed using VS2003 and I need to localize it
into German and French.
(I did not create the project) I have come across a few problems and I
would really appreciate any help.

1. The project is made up of Forms and Panels. I notice that if I click
on
a panel dialog and view its properties then I get no option to set the
localization to true or to change the language for it. How can I localize
a
Panel, I need to do this because the Panel hosts buttons, Labels and Text
boxes.

2. Also I need to localize some of the strings in code. All the examples
I
have seen have walked me through the steps where I create 3 .resx files
e.g
WinFormStrings.resx (English)

WinFormStrings.de-DE.resx
(German)and

WinFormStrings.fr-FR.resx
(French).

See: http://msdn2.microsoft.com/en-US/library/y99d1cd3.aspx.

When I do this the resource manager does not pull out any of the strings I
enter in the resource files. Have I missed something but if you click
'Show
all files' in the Solution explorer is appears that Visual Studio
generates a
.resx file for every Form anyway, so why do we need to add in another one
for
English?

Thanks in advance for any help


--------------------------------
From: Ryan Cush




Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Small Problem with Localizing Forms - 05-19-2006 , 06:18 PM



Yes, you will need to repaint the form if you want to change the UI
language at runtime.

Garrett McGowan [MSFT Developer International]

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------

Quote:
From: Cush (AT) discussions (DOT) microsoft.com
Subject: Re: Small Problem with Localizing Forms
Date: Thu, 4 May 2006 03:54:02 -0700
Newsgroups: microsoft.public.dotnet.internationalization

Thanks Thierry that has fixed my problem. I now have a new issue:
Whenever a form is shown for the first time the InitializeComponent() is
called and this is when the resources are pulled from the required .resx
files. My problem is that I have a Treeview component which simply shown
and
hides forms in a main dialog depending on what node is selected.(All the
forms are initialised when the program launches of course).
Now if I change the language (using a menu selection) and then simply show
one of the forms it does noe use the new resource strings I want!
Is the only way for a form to use the localized .resx file is to be
created
from scratch again?

Thanks.

"Thierry HUGUET [MS]" wrote:

2) I remember to have had already this problem. This is because I didn't
use
set correctly the parameters on the instruction "new ResourceManager".
It is necessary to mention the namespace name before the resource name
(without extension), and it is case sensitive.

INCORRECT: ResourceManager rm = new ResourceManager("resourcefile",
Assembly.GetExecutingAssembly());
CORRECT: ResourceManager rm = new
ResourceManager("MyNameSpace.resourcefile",
Assembly.GetExecutingAssembly());

Thierry HUGUET
Microsoft France


"Cush" <Cush (AT) discussions (DOT) microsoft.com> a écrit dans le message de
news:
D5FEE78F-DF3E-45C7-9A7A-CA9BD987C122...soft (DOT) com...
Hi,
I have a Windows C# app developed using VS2003 and I need to localize
it
into German and French.
(I did not create the project) I have come across a few problems and I
would really appreciate any help.

1. The project is made up of Forms and Panels. I notice that if I
click
on
a panel dialog and view its properties then I get no option to set the
localization to true or to change the language for it. How can I
localize
a
Panel, I need to do this because the Panel hosts buttons, Labels and
Text
boxes.

2. Also I need to localize some of the strings in code. All the
examples
I
have seen have walked me through the steps where I create 3 .resx
files
e.g
WinFormStrings.resx (English)

WinFormStrings.de-DE.resx
(German)and

WinFormStrings.fr-FR.resx
(French).

See: http://msdn2.microsoft.com/en-US/library/y99d1cd3.aspx.

When I do this the resource manager does not pull out any of the
strings I
enter in the resource files. Have I missed something but if you click
'Show
all files' in the Solution explorer is appears that Visual Studio
generates a
.resx file for every Form anyway, so why do we need to add in another
one
for
English?

Thanks in advance for any help


--------------------------------
From: Ryan Cush






Reply With Quote
  #5  
Old   
AndrewEames
 
Posts: n/a

Default Re: Small Problem with Localizing Forms - 05-24-2006 , 07:33 AM



Switching languages on the fly is an interesting problem. I spent a little
time finding a few wrong ways to do this but eventually came up with a cool
generic solution

Basically what you need to do is find all the resources for the new language
and using reflection, you can update all the elemnts on the form. There are a
few gotchas to watch out for.

1) Where do the resources actually come from - this is a little tricky
2) Nested controls that have localized resources
3) Inherited forms/controls
4) A few special cases for ExtenderProvider resources - e.g. Tooltips
5) Switching back to the neutral resources - you will need to identify which
resources to update

Its about 100 lines of code but it will work for any form - I should
probably write this up somewhere if I ever had any time
Andrew
"Cush" wrote:

Quote:
Thanks Thierry that has fixed my problem. I now have a new issue:
Whenever a form is shown for the first time the InitializeComponent() is
called and this is when the resources are pulled from the required .resx
files. My problem is that I have a Treeview component which simply shown and
hides forms in a main dialog depending on what node is selected.(All the
forms are initialised when the program launches of course).
Now if I change the language (using a menu selection) and then simply show
one of the forms it does noe use the new resource strings I want!
Is the only way for a form to use the localized .resx file is to be created
from scratch again?

Thanks.


"Thierry HUGUET [MS]" wrote:


2) I remember to have had already this problem. This is because I didn't use
set correctly the parameters on the instruction "new ResourceManager".
It is necessary to mention the namespace name before the resource name
(without extension), and it is case sensitive.

INCORRECT: ResourceManager rm = new ResourceManager("resourcefile",
Assembly.GetExecutingAssembly());
CORRECT: ResourceManager rm = new
ResourceManager("MyNameSpace.resourcefile",
Assembly.GetExecutingAssembly());

Thierry HUGUET
Microsoft France


"Cush" <Cush (AT) discussions (DOT) microsoft.com> a écrit dans le message de news:
D5FEE78F-DF3E-45C7-9A7A-CA9BD987C122...soft (DOT) com...
Hi,
I have a Windows C# app developed using VS2003 and I need to localize it
into German and French.
(I did not create the project) I have come across a few problems and I
would really appreciate any help.

1. The project is made up of Forms and Panels. I notice that if I click
on
a panel dialog and view its properties then I get no option to set the
localization to true or to change the language for it. How can I localize
a
Panel, I need to do this because the Panel hosts buttons, Labels and Text
boxes.

2. Also I need to localize some of the strings in code. All the examples
I
have seen have walked me through the steps where I create 3 .resx files
e.g
WinFormStrings.resx (English)

WinFormStrings.de-DE.resx
(German)and

WinFormStrings.fr-FR.resx
(French).

See: http://msdn2.microsoft.com/en-US/library/y99d1cd3.aspx.

When I do this the resource manager does not pull out any of the strings I
enter in the resource files. Have I missed something but if you click
'Show
all files' in the Solution explorer is appears that Visual Studio
generates a
.resx file for every Form anyway, so why do we need to add in another one
for
English?

Thanks in advance for any help


--------------------------------
From: Ryan Cush




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.