Changing language by code

Posted by Community Admin on 04-Aug-2018 21:33

Changing language by code

All Replies

Posted by Community Admin on 22-Aug-2016 00:00

Hello,

I have a site with several languages and a language selector. I need to change the site language by code without changing the url.

Currently I'm doing this

Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

This works for labels inside the page, but it always renders the default language version of the page and not the one I need.

Is there any way to achieve this without appending the language prefix to the url?

Posted by Community Admin on 10-Nov-2016 00:00

According to this forum thread: www.sitefinity.com/.../language-selector-and-url-rewriting, the LanguageSelectorControl is checking the UICulture. I'm facing the same problem, and I do not know how to solve it. Anybody?

Posted by Community Admin on 14-Nov-2016 00:00

I had the similar problem in one of mine projects. 

If I got you correct, you have website in many languages. For example:

EN: www.website.com

CN: www.website.cn

And on Chinese website for specific url:  www.website.cn/page-url

you want to show content from page:  www.website.com/page-url

I am not sure if it is possible to do with code. But you can achieve it with rewrite rules and reverse proxy (IIS URL rewrite module & IIS ARR module). Just setup rewrite rule for url: www.website.cn/page- url rewriting content from www.website.com/page-url

This thread is closed