SaaS CMS has officially launched! Learn more now.

Built in auto suggestion wrong language



On the site were working on we use multiple auto suggestion fields. I implemented it as described in 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. 


    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)
        //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?

Jan 16, 2015 12:05
Jan 16, 2015 13:05

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 and click one of the following:

Is it possible to go to

Jan 16, 2015 13:15


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?

Jan 16, 2015 14:44

Hi, thanks for your response.

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

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

Jan 16, 2015 15:05

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:


Jan 16, 2015 15:17

Url: {*}

Jan 16, 2015 15:57


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?

Jan 29, 2015 16:39

No its not solved yet. .nl is mapped to dutch in the host table under website settings as seen in 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:


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

Jan 30, 2015 9:03


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

Jan 30, 2015 10:16

Ok thanls :)

Jan 30, 2015 11:11

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

Feb 26, 2015 7:13

Ok nice :). Thanks alot!

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.