Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Custom PageProvider, Getting Language

Vote:
 

Hi,

I am making a site which uses a Custom PageProvider to show a product database in episerver. The database is localized and now i'm having trouble getting which language the user is asking for.

 

In my GetLocalPage I get an ILanguageSelector which if I understand it correctly should use to find if its being requested a specific language.

In the XmlPageProvider example provided by EPiServer they say you should do something like this.  (language is the ILanguageSelector)

            LanguageSelectorContext context = new LanguageSelectorContext(pageLink);
language.SetInitializedLanguageBranch(context);

string languageCode = context.SelectedLanguage ?? MASTER_LANGUAGE_BRANCH;
But this code always returns the contents of my const MASTER_LANGUAGE_BRANCH which is "sv". It never returns "en" even while vieweing english. 
Am I doing something wrong here? 
 
#32862
Sep 22, 2009 10:18
Vote:
 

Hi!

I just had the same problem, and found out that I needed to add MultiLanguage in the capabilities attribute in the pageProvider section in web.config. (I know this answer is a little late for you, but I'm posting this because somebody else might have the same problem... :-)

 

    <pageProvider>
      <providers>
        <add name="XmlPageProvider" type="CodeSamples.XmlPageProvider, XmlPageProvider"   entryPoint="3" capabilities="Create,Edit,Delete,Move,Copy,MultiLanguage" filePath="~\externalpages.xml"/>
      </providers>
    </pageProvider>   

#37600
Mar 12, 2010 14:11
* 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.