This is a migrated thread and some comments may be shown as answers.

Changing culture at runtime

9 Answers 1222 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christie Admin
Top achievements
Rank 1
Christie Admin asked on 29 Oct 2015, 02:45 PM

Hi,

 

in our application we have the flexibility to change the culture at runtime and I would like to know if it's possible with Telerik?

 

Thank'

Alain

9 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 03 Nov 2015, 02:47 PM
Hello,

Yes, it's possible to change the culture at runtime. You can set it programmatically.
Thread.CurrentThread.CurrentCulture = new CultureInfo("de");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
You can read more about this in our Localization article.

If you have any other questions, please don't hesitate to contact us again. 

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Christie Admin
Top achievements
Rank 1
answered on 03 Nov 2015, 02:55 PM

Hi Dinko,

 

this will change Telerik controls also (ie: RadScheduleView)???

 

Thank's

Alain

0
Dinko | Tech Support Engineer
Telerik team
answered on 06 Nov 2015, 02:41 PM
Hello Alain,

You can change the localization of RadScheduleView at runtime in a few steps. Firstly you can set the
DefaultCulture property of the LocalizationManager to the new culture. Then you need to reset the template of the RadScheduleView control in order for the changes to take effect. For example:
var cultureInfo = new CultureInfo("de-DE");
LocalizationManager.DefaultCulture = cultureInfo;
var myTemplate = this.MyScheduleView.Template;
this.MyScheduleView.Template = null;
this.MyScheduleView.Template = myTemplate;
I have created a sample project using the code snippet above to see how you can implement the scenario.
You can also check the Localization help article and demo.

Hope this will help.

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Christie Admin
Top achievements
Rank 1
answered on 06 Nov 2015, 03:01 PM

Great Dinko :)

 

actually in our application we have multiple differents Telerik controls which can be created at the same time so I would like to know if it's possible when the localization of our application changeg, if I there is a way to search for all created Telerik controls an apply your logic to each one???

 

Thank's

Alain

0
Dinko | Tech Support Engineer
Telerik team
answered on 10 Nov 2015, 05:47 PM
Hi Alain,

You can change the localization of the Telerik controls at runtime in two ways. The first one is to set the static UseDynamicLocalization property of the LocalizationManager to true before calling the InitializeComponent() method of the application. This way when you change the localization manager's culture, the localized strings of the control will be updated. Keep in mind that this functionality is implemented only for part of our controls. For example, RadGridView and RadScheduleView won't work using this approach. The second one is to reset the template of the control as demonstrated in my previous answer. 

To get all Telerik controls in your application, you can subscribe for their Loaded event using EventManager.RegisterClassHandler() method and store them in a collection. Then you can iterate through the collection and reset the templates of all it's elements.
EventManager.RegisterClassHandler(typeof(Control), Control.LoadedEvent, new RoutedEventHandler(OnControlLoaded));
Or you can use the ChildrenOfTypeExtensions.ChildrenOfType<T>() method to get all Telerik controls when you change the culture.

Also, I have created a sample project with several Telerik controls where you can see how to implement these approaches. 

Regards,
Dinko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lukas
Top achievements
Rank 1
answered on 16 Nov 2017, 03:54 PM

I have (still) the same problem.

Your recent sample, Dinko, solved most problems.But, the view selection button (navigation bar) is still not updated after culture change.

I would like to continue use our current version (2016.2.613), but I've also tested recent version (2017.3.1018).

What I have to do, do get navigation but to be updated too.

Thanks
Lukas

0
Lukas
Top achievements
Rank 1
answered on 16 Nov 2017, 04:13 PM
Further, the internal dialogs (create new appointment, delete appointment confirmation) are always english, even the application starts with german culture.
0
Martin Ivanov
Telerik team
answered on 20 Nov 2017, 07:22 AM
Hello Lukas,

I wasn't able to reproduce the mentioned issues. The dialogs and the buttons language is changed properly. I also answered your ticket. Can you please get back there with more information on the matter.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ankita
Top achievements
Rank 1
answered on 13 Jan 2018, 08:02 AM
Thanks @Dinko
Tags
General Discussions
Asked by
Christie Admin
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Christie Admin
Top achievements
Rank 1
Lukas
Top achievements
Rank 1
Martin Ivanov
Telerik team
Ankita
Top achievements
Rank 1
Share this question
or