3

Firstly, please check this: http://ws.luyencong.net/data/search/query.php?do=advanced

You can paste all the content of that JSON to here : http://pro.jsonlint.com/

Now you can see the content of that JSON is in Vietnamese. And well, I want when user search they can search with UTF-8 character.

For example: You type in the search box character 'ô', the suggestion should displays. (Typeahead.js now can't do that).

Is there any way can do my requirements ?

Edit :

You can see a live demo at http://www.luyencong.net (type a character in search box)

LCTG
  • 250
  • 1
  • 3
  • 14
  • Could you create a fiddle: http://jsfiddle.net/ ? – Hieu Nguyen Jul 20 '13 at 14:34
  • You can check a live demo here : http://www.luyencong.net/ In the search box, type something like `ô` or `đ` – LCTG Jul 20 '13 at 16:49
  • I mean without seeing any code, it's quite difficult to figure out the problem. At least edit your question to add how did you initialize the `typeahead` in JS – Hieu Nguyen Jul 20 '13 at 18:19

1 Answers1

3

It's not an elegant solution, but you could take advantage of custom tokens to get transliteration support. For example, if you had the following datum:

{
  "value": "limón fútbol"
} 

By default, it would get tokenized into ['limón', 'fútbol']. If you explicitly set the tokens yourself however, you could do something like this:

{
  "value": "limón fútbol",
  "tokens": ["limon", "limón", "futbol", "fútbol"]
}

Now if you searched for limon or futbol, this datum would be show as a suggestion.

jharding
  • 1,404
  • 10
  • 17
  • I tried. But not work :( Please take a look in my JSON, is that correct ? http://ws.luyencong.net/data/search/query.php?do=advanced – LCTG Jul 22 '13 at 08:13
  • 1
    The values in `tokens` need to already be tokenized. So rather than `tokens: ["Hoang Kim Dong", "An Su"]`, it should be `tokens: ["Hoang", "Kim", "Dong", "An", "Su"]`. – jharding Jul 22 '13 at 17:28