Change episerver user language programmatically



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

Aug 04, 2020 12:35

i have tried this code: 

var user = EPiServerProfile.Current;
user.Language = "da";

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

Aug 04, 2020 14:56

Hi Lars

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

Aug 04, 2020 17:16

Hi Lars,

Try the below code-piece.

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

Aug 05, 2020 10:38

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?

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.