London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Translations always showing english in globalized site

Vote:
 

I have an issue with a globalized multi-site always showing english XML texts - regardless of what site language is set.

This happened after the upgrade to 7. I have installed all of the latest patches for 7.

Any ideas?

#73311
Jul 15, 2013 11:44
Vote:
 

I'm suspecting this change in web.config may have something to do with it:

CMS6:

<globalization culture="en-US" uiCulture="en" requestEncoding="utf-8" responseEncoding="utf-8" resourceProviderFactoryType="EPiServer.Resources.XmlResourceProviderFactory, EPiServer" />

 

CMS7:

<globalization culture="en-US" uiCulture="en" requestEncoding="utf-8" responseEncoding="utf-8" resourceProviderFactoryType="EPiServer.Framework.Localization.LocalizationServiceResourceProviderFactory, EPiServer.Framework" />

#73313
Jul 15, 2013 12:03
Vote:
 

Hi, Oerjan,

The setting in web.config is correct.

How do you translate? Do you use LocalizationService.Current.GetString("/xx/yy")?

#73316
Jul 15, 2013 13:42
Vote:
 

Hi,

I've tried both LocalizationService.Current.GetString("/xx/yy") and the obsolete way LanguageManager.Instance.Translate("/xx/yy").

#73317
Jul 15, 2013 13:52
Vote:
 

If I understand your problem correctly, this is bug #95725

 

http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=71948

#73323
Jul 15, 2013 19:42
Vote:
 

Alf:

Yes, it fits my description, except for this part: "When browing in View mode (outside EPiServer UI) everything seems ok, I can switch language by browsing with different language prefix in the url exactly like everything is supposed to behave."


In that case, I guess my translations should have been displayed just fine when I'm viewing the page not-logged in?

#73337
Jul 16, 2013 8:07
Vote:
 

Yes, that's correct. I only had this problem when I'm in Edit mode. While in View mode/not logged in I had no problems at all.

Could you check what preferred language you're on when browsing?

#73346
Jul 16, 2013 8:56
Vote:
 

When debugging, I see that CultureInfo.CurrentUICulture is "en" when it should have been norwegian "no".

ContentLanguage.PreferredCulture however, is "no".

#73362
Edited, Jul 16, 2013 12:30
Vote:
 

Same problem here Ørjan. Solution is EPiServer 7.1 with two languages, Norwegian and English. On English pages all of the lang text is in Norwegian. 

 

When on "/en" page following happens:

<% = CultureInfo.CurrentUICulture.DisplayName %>

shows Norwegian

<%= CurrentPage.Language.DisplayName %>

shows English

 

According to EPiServer support "CultureInfo.CurrentUICulture" is used in all of the following:

<EPiServer:Translate Text="/bw/usercontrols/logIn/mypage" runat="server" />

 

<%= LocalizationService.Current.GetString("/bw/usercontrols/logIn/mypage") %>

<%= Translate("/bw/usercontrols/logIn/mypage") %>

 

This one works however, but shouldn't be necessary:

<%=LocalizationService.Current.GetStringByCulture("/bw/usercontrols/logIn/mypage", CurrentPage.Language)%>

 

One more thing is that Translate seems to work only for one language at a time. Changing configuration from

<globalization culture="nb-NO" uiCulture="no"

to

<globalization culture="en-US" uiCulture="en"

shows lang text in English on both "/en" and "/no" pages.

 

I'm in dialog with EPiServer support, and will post any new findings here.

#82623
Edited, Mar 17, 2014 12:41
Vote:
 

This did it for me!

Fix for Webforms is to make all UserControls inherit from SiteUserControl<SitePageData> and all templates fromSiteTemplatePage<SitePageData>. You can then simply set CurrentUICulture inside constructor for SitePageData:

 

public class SitePageData : PageData

{

    public SitePageData()

    {

        if (ContentLanguage.PreferredCulture.LCID != Thread.CurrentThread.CurrentUICulture.LCID)

        {

                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ContentLanguage.PreferredCulture.LCID);

        }

    }

}

 

Fixfor Mvc is to make all of your Controllers inherit from BasePageController and add following override:

 

protected override IAsyncResult BeginExecute(System.Web.Routing.RequestContext requestContext, AsyncCallback callback, object state)

{

    if (ContentLanguage.PreferredCulture.LCID != Thread.CurrentThread.CurrentUICulture.LCID)

    {

        Thread.CurrentThread.CurrentUICulture = new CultureInfo(ContentLanguage.PreferredCulture.LCID);

    }

}

#82665
Mar 18, 2014 9:01
Vote:
 

Small adjustment for Webforms projects. Adding following code to SiteMasterPage which all of the other masterpages inherit from did the trick for me.

protected void Page_Init(object sender, EventArgs e)
{
   if (ContentLanguage.PreferredCulture.LCID != Thread.CurrentThread.CurrentUICulture.LCID)
   {
      Thread.CurrentThread.CurrentUICulture = new CultureInfo(ContentLanguage.PreferredCulture.LCID);
   }
}

#82680
Mar 18, 2014 10:31
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.