473,669 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing Localization on the fly

I've got a windows forms application that uses french and english. We're
localizing it right now. It does appear to work if I set the language

Thread.CurrentT hread.CurrentCu lture = new CultureInfo("fr-CA");
Thread.CurrentT hread.CurrentUI Culture = new CultureInfo("fr-CA");

Just before we run it.

How can I setup a button that will toggle the language while the program is
running? It seems once it's running, changing the language has no effect.

Thanks,
Greg
Nov 3 '08 #1
6 13200
"greg" <th*****@nospam .nospamwrote in message
news:53******** *************** ***********@mic rosoft.com...
I've got a windows forms application that uses french and english. We're
localizing it right now. It does appear to work if I set the language

Thread.CurrentT hread.CurrentCu lture = new CultureInfo("fr-CA");
Thread.CurrentT hread.CurrentUI Culture = new CultureInfo("fr-CA");

Just before we run it.

How can I setup a button that will toggle the language while the program
is
running? It seems once it's running, changing the language has no effect.
The language is processed in the Constructor of the Form. So once a form
is already constructed, it won't change language. After you change the
Thread.CurrentT hread.CurrentUI Culture, new forms that you open will show in
the new language, but the form itself from which you executed that change,
as well as any previously opened forms, will not change. You can close and
reopen the current form if you want it to show in the new language.

Nov 3 '08 #2
Localization data(strings and other data if any) are stored in satellite
dlls. So, once a dll is loaded, you can't unload that dll and load
another dll. The only way to change that (as far as I know) is to
restart your application. It applies to both .Net applications and MFC
applications.

Thanks & Regards,
Ashutosh

greg wrote:
I've got a windows forms application that uses french and english. We're
localizing it right now. It does appear to work if I set the language

Thread.CurrentT hread.CurrentCu lture = new CultureInfo("fr-CA");
Thread.CurrentT hread.CurrentUI Culture = new CultureInfo("fr-CA");

Just before we run it.

How can I setup a button that will toggle the language while the program is
running? It seems once it's running, changing the language has no effect.

Thanks,
Greg
Nov 3 '08 #3
Hi Greg,

you can change it, look how it's done in
Windows Form Designer generated code.

Basically it's working like this:
private void localize(Cultur eInfo culture)
{
Thread.CurrentT hread.CurrentUI Culture = culture;

foreach (Form form in Application.Ope nForms)
ApplyControlRes ources(new
ComponentResour ceManager(form. GetType()), form);
}

private void ApplyControlRes ources
(ComponentResou rceManager resourceManager , Control control)
{
if (control is Form)
resourceManager .ApplyResources (control, "$this");
else
resourceManager .ApplyResources (control, control.Name);

if (control is IContainerContr ol)
{
foreach (Control childControl in control.Control s)
{
ApplyControlRes ources(resource Manager, childControl);
}
}
}

Additional, you have to iterate through each forms menus and do the same.

Walter
Nov 4 '08 #4
Hi Greg,

Walter has provided a great solution to this question.

This solution works because the ComponentResour ceManager.Apply Resources
will load the resource dll at runtime. It will not impact the performance
because the loading will only happen in the first time to apply the
resource and later the resource dll will stay in memory.

Please try Walter's solution and let us know if you have any problem when
implementing it. Thanks.

Regards,
Hongye Sun (ho*****@online .microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 4 '08 #5
On Nov 4, 2:43*am, greg <thef...@nospam .nospamwrote:
I've got a windows forms application that uses french and english. We're
localizing it right now. It does appear to work if I set the language

* Thread.CurrentT hread.CurrentCu lture = new CultureInfo("fr-CA");
* Thread.CurrentT hread.CurrentUI Culture = new CultureInfo("fr-CA");

Just before we run it.

How can I setup a button that will toggle the language while the program is
running? It seems once it's running, changing the language has no effect.
Have a look at the following article on code project:

http://www.codeproject.com/KB/cs/CultureManager.aspx

It provides a component that allows you to change the active culture
of all forms/controls in your application.

Regards
Grant Frisken
Infralution

Infralution Globalizer.NET - localization made easy
www.infralution.com/globalizer.html
Nov 4 '08 #6
Hi Greg,

I have not heard from you for several days. I am writing to check the staus
of this issue. Would you mind letting us know any progress from your side?
If you have any problem regarding this issue, please feel free to let us
know. It is our pleasure to help you. Thanks.

Have a nice day.

Regards,
Hongye Sun (ho*****@online .microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
*
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 14 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1582
by: Sebastian Bargmann | last post by:
Hi, I think I've read everything there is to read about localization in dotNET and I still don't get it. I understand the concepts and I understand the code, but there's no way that the scenarios described can be translated(!) to a real world application. Here's what I got. I have forms with controls on them and I have constant strings that I show in message boxes and the like.
2
1927
by: Kallis | last post by:
Hello, I have the following situation when trying to localize my software: I have BIG solution with about 80 projects. In one of the projects I have a number of dialogs (the dialog project :-) ). I have decided that I do not want to use the "form"-mechanism (using the property "localized=true") for localization since the strings I show are not that "constant" during the life time of the dialog. Thus, I have to put the resources in...
4
2982
by: Weinand Daniel | last post by:
i'd like to monitor changes of the "Control.Name" porperty during designtime. if the user changes the name in designer my event musst fire. i have created a own button control. with an event NameChange. during runtime it works fine. if the name of the control has changed the event is fireing. (for example: designtime name of the button is btnOk, on a second button
1
2697
by: enahar | last post by:
Dear Sir/Madam We are going to do the Localization/Globalisation for our product which has nearly got 284 forms using satellite Assemblies. I have got 2 questions 1. How to handle Substrings. 2.What issues can you think could come across during Globalization/Localisation. 3. How to develop an utility(can anybody share the code) which will display the only the text values from the resource files and allow to enter new
4
1194
by: Matthias S. | last post by:
Hi everybody, I'm starting to design a Portal-Style application which should support a couple of languages. What I figured is that one could use various resx files to localize more or less "static" information such as labels and short text blocks. But what about Lookup-Table-Data stored in the SQL Server. Say I have a table containing Priorities ("High", "AboveNormal", "Normal", "BelowNormal", "Low"). This table is used to fill a...
8
3713
by: Henry | last post by:
Hi, in a Windows form VB.Net project I use localization for all texts. In App.Config I added: <appSettings> <add key="locale" value="de"/> </appSettings> In the project I have ressource files strings.resx (English text) and strings.de.resx for the German texts.
5
2405
by: archana | last post by:
Hi all, I am having confusion regarding localization in .net. I have one form on which i have some labels and button. After designing that form what i did is set localization property of form to true and i set language as french. But still it is not changing caption of controls which are there in form.
2
1148
by: Robert Dufour | last post by:
In an english only application, it is fairly easy to make the table and field names in your application descriptive so that on creating the interface, most tools that bind data take the default field name and put it as the column name in say a grid control. However if you have a multi lingual UI you can localize the UI in Vs 2005 by selecting the language of the form and changing the text property of the controls to the localized text....
2
2582
by: Chris Walls | last post by:
We have created two (2) global resource files in App_GlobalResouces: Global.resx Global.es-MX.resx In an ASP.NET page, we use two different syntaxes to set text on the page, depending upon the context. Syntax 1: <% =Resources.Global.QuickSearch%> Syntax 2: <%$Resources:Global, QuickSearch%> When we set our Thread.CurrentThread.CurrentUICulture and
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8896
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7410
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6211
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1790
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.