Click here to Skip to main content
15,894,306 members
Home / Discussions / C#
   

C#

 
GeneralActive Directory Exception Pin
vcorn26-Jul-04 20:36
vcorn26-Jul-04 20:36 
GeneralRe: Active Directory Exception Pin
Dave Kreskowiak27-Jul-04 6:38
mveDave Kreskowiak27-Jul-04 6:38 
GeneralRe: Active Directory Exception Pin
vcorn27-Jul-04 19:44
vcorn27-Jul-04 19:44 
Generalproblems with drawing a PieChart Pin
Pain_Elemental26-Jul-04 20:28
Pain_Elemental26-Jul-04 20:28 
GeneralRe: problems with drawing a PieChart Pin
Heath Stewart27-Jul-04 11:07
protectorHeath Stewart27-Jul-04 11:07 
GeneralRe: problems with drawing a PieChart Pin
Pain_Elemental28-Jul-04 5:50
Pain_Elemental28-Jul-04 5:50 
Generalsupporting localization Pin
samithas26-Jul-04 18:19
samithas26-Jul-04 18:19 
GeneralRe: supporting localization Pin
Heath Stewart26-Jul-04 18:32
protectorHeath Stewart26-Jul-04 18:32 
The first thing to do would be to read Developing World-ready Applications[^] in the .NET Framework SDK.

Creating different forms for different cultures is not only inefficient but incredibly inflexible. Doing things the right way, you need only add localization code (documented in the topic above) and for each language you want to support, override the strings, sizes, locations, etc. (as necessary - not all always need to be changed) in a satellite assembly. VS.NET can help you do this using the form designer (though it's important to understand what's happening, otherwise you're not actually developing anything) but it won't help you switch languages on the fly.

To do that, you have to break the designer. Change InitializeComponent so that it doesn't instantiate the controls (move instantiation in the top of that method to the constructor) and only makes calls to ResourceManager.GetObject (or, from the designer in VS 2005, ComponentResourceManager.ApplyResources). When you switch languages, set Thread.CurrentUICulture to the CultureInfo you want (like new CultureInfo("de-DE") for the German language in the country of Germany) and call the method InitializeComponent again to reset the localized resources.

Do this after changing the form's Localized property to true, which will add the necessary code.

When localizing, localize all properties attributed with LocalizableAttribute(true). The neutral language (the language in which the primary assembly was written, which should contain the neutral language resources) must contain all the localized resources (which is another reason for placing these in the primary assembly); the satellite assemblies can be added later and used automatically by .NET without changing a single line of code.

Fusion, the assembly binder, looks for satellite assemblies for the Thread.CurrentUICulture when binding an assembly. If no assembly is found, the neutral language resources in the primary assembly (the assembly that contains code - not just resources). In order to expediate this behavior, use the NeutralResourcesLanguageAttribute at the assembly level (prefixed with [assembly: ...] along with the neutral language (if developing assemblies in US English, you'd put "en-US" as the constructor parameter).

 

Microsoft MVP, Visual C#
My Articles
GeneralIssue on replacing WebBrowser context menu Pin
w1424326-Jul-04 16:26
w1424326-Jul-04 16:26 
GeneralRe: Issue on replacing WebBrowser context menu Pin
Heath Stewart26-Jul-04 18:20
protectorHeath Stewart26-Jul-04 18:20 
Generalprinting a form Pin
stevemasters2226-Jul-04 15:31
stevemasters2226-Jul-04 15:31 
GeneralBinding DataView to MSChart Pin
Kuan Wai Mun26-Jul-04 15:04
Kuan Wai Mun26-Jul-04 15:04 
GeneralRe: Binding DataView to MSChart Pin
Heath Stewart26-Jul-04 18:50
protectorHeath Stewart26-Jul-04 18:50 
GeneralRe: Binding DataView to MSChart Pin
Kuan Wai Mun2-Aug-04 17:36
Kuan Wai Mun2-Aug-04 17:36 
GeneralScrollBars for DataGrid Pin
Khang Nguyen26-Jul-04 14:43
Khang Nguyen26-Jul-04 14:43 
GeneralRe: ScrollBars for DataGrid Pin
DougW4826-Jul-04 15:33
DougW4826-Jul-04 15:33 
GeneralRe: ScrollBars for DataGrid Pin
Khang Nguyen27-Jul-04 6:11
Khang Nguyen27-Jul-04 6:11 
Generalproblems by "add web reference" in https Pin
Stephan Wright26-Jul-04 12:42
Stephan Wright26-Jul-04 12:42 
GeneralRe: problems by "add web reference" in https Pin
Heath Stewart27-Jul-04 11:04
protectorHeath Stewart27-Jul-04 11:04 
GeneralRe: problems by "add web reference" in https Pin
Stephan Wright27-Jul-04 22:12
Stephan Wright27-Jul-04 22:12 
GeneralRe: problems by "add web reference" in https Pin
Heath Stewart28-Jul-04 4:16
protectorHeath Stewart28-Jul-04 4:16 
GeneralDataView.Sort does NOTHING Pin
Christian Graus26-Jul-04 11:34
protectorChristian Graus26-Jul-04 11:34 
GeneralRe: DataView.Sort does NOTHING Pin
Heath Stewart26-Jul-04 11:56
protectorHeath Stewart26-Jul-04 11:56 
GeneralRe: DataView.Sort does NOTHING Pin
Christian Graus26-Jul-04 12:02
protectorChristian Graus26-Jul-04 12:02 
GeneralRe: DataView.Sort does NOTHING Pin
Roman Rodov26-Jul-04 14:42
Roman Rodov26-Jul-04 14:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.