November Happy Hour will be moved to Thursday December 5th.

Change episerver user language programmatically

Vote:
 

Hi

Is it possible to change a episerver uses language programmatically?

We have many (>10000) users and i need to set all language to danish. I tried to change it directly in the database in the Profiles table of the membership database, and that does change the "Personal Language" setting on the Display Options tab but it does not change the language anyware else. I tried resetting IIS and use inconito browser but the issue persists. So i must do something wrong maybe i can use an API instead of direct manipulation in the database?

I am on a 2 month old version of Episerver

#226095
Aug 04, 2020 12:35
Vote:
 

i have tried this code: 

var user = EPiServerProfile.Current;
user.Language = "da";
user.Save();

i changes the language in the database and in the "Personal Language" setting but episerver still uses the old language.

By the way if i change the language in episerver in the "Personal Language" setting then it works

#226098
Aug 04, 2020 14:56
Vote:
 

Hi Lars

Try adding a call to ICurrentUiCulture.Save(string userName, CultureInfo culture) to your code-piece.

#226103
Aug 04, 2020 17:16
Vote:
 

Hi Lars,

Try the below code-piece.

var profile = EPiServerProfile.Wrap(ProfileBase.Create(result.Username));
profile.Language = "da";
profile.Save();

#226141
Aug 05, 2020 10:38
Vote:
 

adding this fixed the problem:

ServiceLocator.Current.GetInstance<ICurrentUiCulture>().Save(user.UserName, CultureInfo.GetCultureInfo("da"));

Thanks Stefan

Any idear where the information is saved in the database?

#226171
Aug 06, 2020 5:55
Stefan Holm Olsen - Aug 06, 2020 6:56
Great to hear that it worked out.
I believe it is stored somewhere in DDS, which is a big black box. I recommend that you don’t touch those database tables directly.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.