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

Built in auto suggestion wrong language

Vote:
 

Hi,

On the site were working on we use multiple auto suggestion fields. I implemented it as described in http://world.episerver.com/blogs/Linus-Ekstrom/Dates/2014/7/Built-in-auto-suggestion-editor/. It works except when i change the locale in episerver cms, ContentLanguage.PreferredCulture gives me the language of the host and not the one I selected. 

Code:

	[ServiceConfiguration(typeof(ISelectionQuery))]
    public class AMPromotionSelectionQuery : ISelectionQuery
    {
        List _items;

        private IPromotionService _promotionService;

        public AMPromotionSelectionQuery(IPromotionService promotionService)
        {
            _promotionService = promotionService;

            _items = _promotionService.GetActionModulePromosForCms(ContentLanguage.PreferredCulture.TwoLetterISOLanguageName)
                .Select(x => new SelectItem()
            {
                Text = x.Name,
                Value = x.Id
            }).OrderBy(x => x.Text)
            .ToList();
        }       
        
        //Will be called when the editor types something in the selection editor.        
        public IEnumerable GetItems(string query)
        {
            return _items.Where(i => i.Text.StartsWith(query,StringComparison.InvariantCultureIgnoreCase));
        }        
        
        //Will be called when initializing an editor with an existing value to get the corresponding text representation.       
        public ISelectItem GetItemByValue(string value)
        {
            return _items.FirstOrDefault(i => i.Value.Equals(value));
        }
    }

So when calling ContentLanguage.PreferredCulture.TwoLetterISOLanguageName I get "nl" back, but the content language selected is "de". What can I do to fix this?

#115705
Jan 16, 2015 12:05
Vote:
 
#115715
Jan 16, 2015 13:05
Vote:
 

Another way to fix this is to change hosts when selecting a language. Is there a way to do that? 

So I have 3 hosts configured. 1 for en, 1 for de and one for nl. when im on http://site.nl/episerver and click one of the following:

http://screencloud.net/v/m4va

Is it possible to go to http://site.de/episerver?

#115717
Jan 16, 2015 13:15
Vote:
 

Hi!

As you mention, the cause of the problem is that the URL to the suggestion service does not append language information. If you register specific URL:s for each language (under Manager Website Languages) I hope that this will work, though I have tried this yet. Have you done to Niels and if so, does it solve it?

#115722
Jan 16, 2015 14:44
Vote:
 

Hi, thanks for your response.

Could not find a field where i can do that. In this image you can see my configuration.

http://snag.gy/qKkXX.jpg

As you can see in the bottom part is that on the manage website languages there is no option to configure a url.

#115724
Jan 16, 2015 15:05
Vote:
 

Hmm, that sounds like the correct set up. Could you see what the URL is to the selection Service when you are on a second language getting the failure? For instance, my URL looks like this in a development environment:

/EPiServerMVC3/EPiServer/Shell/stores/selectionquery/EPiServer.Templates.Alloy.Business.EditorDescriptors.SampleSelectionQuery/?name=a*

#115725
Jan 16, 2015 15:17
Vote:
 

Url: {http://local.######.nl/EPiServer/Shell/stores/selectionquery/######.Website.SelectionFactories.AMPromotionSelectionQuery/?name=*}

#115727
Jan 16, 2015 15:57
Vote:
 

Hi!

It this still an issue or have you solved it? If not, is *.nl mapped to Dutch and is this what you are getting in the service or is it falling back to another language?

#116406
Jan 29, 2015 16:39
Vote:
 

No its not solved yet. .nl is mapped to dutch in the host table under website settings as seen in http://snag.gy/qKkXX.jpg. And I am seeing the correct language. Also when changing the language under the page settings or under CMS->Edit->Sites the correct language is shown. The problem is really in the auto suggestion ajax call. Cause when changing the language the host does not change, only the url query parameters. For example:

http://local.*****.nl/EPiServer/CMS/?language=de#context=epi.cms.contentdata:///5

And in the ajax call it still thinks its dutch, even though it should be german. 

#116450
Jan 30, 2015 9:03
Vote:
 

Hi!

I think I've found what's missing and a temporary work around. If you browse directly to the UI for the URL that's mapped to the language, content language will follow the UI. However, if you use the site switcher to switch language the URL will not be changed. Instead, a header value is passed into the requests by our REST store on the client. This is however not done for the auto suggestion editors which are using the default Dojo REST store. I've registered a bug for this and hopefully, it should be pretty easy to fix:

Bug #122418: Auto Suggestion editors does not handle content language

#116457
Jan 30, 2015 10:16
Vote:
 

Ok thanls :)

#116463
Jan 30, 2015 11:11
Vote:
 

This bug has now been fixed and will be released within a few weeks.

#118019
Feb 26, 2015 7:13
Vote:
 

Ok nice :). Thanks alot!

#118021
Feb 26, 2015 7:37
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.