Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Jarvis 6 posts 38 karma points
    Jan 06, 2017 @ 11:13
    Matthew Jarvis
    0

    Help for showing multilingual search results

    Hi,

    I have a multilingual site (English and Welsh).

    Been playing around with the XSLT file to try to get preview fields to display content in the correct language

    E.g at the moment, if I search 'Sport (an English search term)' or 'Chwaraeon (a Welsh search term), both preview results are shown in English.

    Example here

    English - http://www.cymoedd.ac.uk/search.aspx?search=sport Welsh - http://www.cymoedd.ac.uk/search.aspx?search=chwaraeon

    What I would want is preview results to show English if an English search term is used, and Welsh if Welsh is used.

    My English/Welsh content is defined via an alias e.g bodyTextEN, bodyTextCY

    Any help or suggesstion would be greatly appreciated.

    Thanks

    Matt

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 06, 2017 @ 12:03
    Douglas Robar
    100

    Hi, Matthew,

    XSLTsearch assumes you'd have different sections in your content tree for each language. Something like:

    CONTENT  
      English  
      - Page 1  
      - Page 2  
      - Page 3  
      - Search
      Welsh  
      - Welsh Page 1  
      - Welsh Page 2  
      - Welsh Page 3  
      - Welsh Search
    

    Each search page (the english one and the welsh one) would search within the portion of the content tree that it is in. That's the default behavior and the expectation XSLTsearch has of the content tree structure.

    Your site, if I understand correctly, has a single structure for both languages together, and different properties for each language. This is more typical of what's called a one-to-one or 1:1 pattern. (The excellent Vorto package can help with that if you're not using it.)

    The 1:1 pattern isn't what XSLTsearch was designed for. So it'll take a bit of tweaking to sort it out.

    The easiest option would be to create two search pages, one for English and one for Welsh.

    CONTENT  
      Home  
      - Page 1  
      - Page 2  
      - Page 3  
      - Search  
      - Chwilio
    

    (Google tells me chwilio is Welsh for search. Forgive me if I've gotten it totally wrong in these examples!)

    I'm going to assume that you can use the umbracoNaviHide property to hide the Search and Chwilio pages from the site's navigation, sitemap, and search results. That way visitors don't know you have two different search pages.

    Each search page (english and welsh) will have different parameters to the macro for the fields to search and preview. On the english page you'd use the bodyTextEN field, for example, and on the Welsh search page you'd use the bodyTextCY field.

    Since you've got a site search box in the header of every page you could use a bit of javascript to update the href="/search.aspx" to be href="/chwilio.aspx" when your visitors choose the welsh site (via the language cookie you're setting).

    There are other options, such as passing the language in as a search parameter and then modifying the xsltsearch.xslt file to notice that and update the field names to append it so you search within the correct language properties. That's much more effort, though, and would hamper any upgrades to XSLTsearch itself.

    Also, look in to ezSearch, which works the same way as XSLTsearch and is preferred over the older XSLTsearch. (It uses Razor and Examine rather than XSLT so it's both faster and easier to modify if you need to).

    Hope this helps as you consider how to architect the best solution.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft