[Search wiki] Non-english mini-articles

jer jeremie at jabber.org
Sat Jan 12 23:26:42 UTC 2008


I did some research and there isn't any compatible way of getting the  
equivalent of the accept-language header in javascript.  You're  
suggestion to do this in the php that returns the JSON MA seems like  
a great next step :)

Jer

On Jan 11, 2008, at 7:22 AM, Balinny wrote:

> jer wrote:
>> Maybe this has been resolved already and I'm just unaware, but how
>> exactly should the search client (the html/js at re.search.wikia.com)
>> detect the browser's language and pull in the appropriate language
>> miniarticle?  I'd be happy to code something in the JavaScript if
>> anyone had pointers on the right thing to do?
>>
> You'd need to pull it from the accept-language header. but i don't   
> have
> any idea on how to
> do it with javascript.
>
> How is wfGetArticleJSON() implemented?
>
>
> I'd do it there, with something like:
> function wfGetArticleByUserLanguageJSON($title, $lang)  {
> if (!is_set($lang))
>   $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
> $Languages = ParseAcceptLanguages($lang);
>
> foreach $Languages as $lng {
>   $TitleObj = Title::newFromText("$title/$lng");
>   if (page_exists)
>       return page_content . '<p style="text-align: right"><a href="' .
> Title::newFromText("Special:Prefixindex")->getFullURL("namespace=" .
> $TitleObj->getNamespace() . "&from=" . $title) . '">' .
> wfMsg('view-in-other-languages') . "</a></p>"; //FIXME: wfMsg is not
> aware of the $lang supplied here...
> }
>
> //Do the same as current wfGetArticleJSON()
> $TitleObj = Title::newFromText("$title");
>   if (page_exists)
>      return Content;
> }
> $wgAjaxExportList[] = 'wfGetArticleByUserLanguageJSON';
>
> Where ParseAcceptLanguages($str); parses an Accept Language header and
> returns an array of the
> user accepted languages sorted by priority (;q=n), removes variants  
> when
> needed, etc.
>
>
> _______________________________________________
> Search wiki mailing list
> http://search.wikia.com/
> http://lists.wikia.com/mailman/listinfo/searchwiki



More information about the SearchWiki mailing list