[Sugar-devel] [PATCH Browse] Use user's LANG for search results SL #3445

Manuel Quiñones manuq at laptop.org
Thu May 3 22:23:20 EDT 2012


2012/5/3 Manuel Quiñones <manuq at laptop.org>:
> 2012/5/3 Manuel Kaufmann <humitos at gmail.com>:
>> When the user types a string that is not like an url, we use Google to
>> search that string with the results in the language defined by LANG
>> environment variable.
>
> Yes as discussed with Gonzalo, this is a better way to handle the
> downloads, because if a translator makes a mistake the search will
> fail.  Better to use the LANG variable.  Tested with the XO in German.

s/downloads/searches

So many Browse tickets in my mind :)

>
>> Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
> Acked-by: Manuel Quiñones <manuq at laptop.org>
>
>> ---
>>  browser.py |   10 +++++++---
>>  1 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/browser.py b/browser.py
>> index c0bb7bc..0af4eb6 100644
>> --- a/browser.py
>> +++ b/browser.py
>> @@ -134,12 +134,16 @@ class TabbedView(BrowserNotebook):
>>                 pass
>>
>>         if soup_uri is None and not _NON_SEARCH_REGEX.match(url):
>> +            # Get the user's LANG to use as default language of
>> +            # the results
>> +            lang = os.environ.get('LANG', 'en')[:2]
>>             # If the string doesn't look like an URI, let's search it:
>> -            url_search = \
>> -                _('http://www.google.com/search?q=%s&ie=UTF-8&oe=UTF-8')
>> +            url_search = 'http://www.google.com/search?' \
>> +                'q=%(query)s&ie=UTF-8&oe=UTF-8&hl=%(lang)s'
>>             query_param = Soup.form_encode_hash({'q': url})
>>             # [2:] here is getting rid of 'q=':
>> -            effective_url = url_search % query_param[2:]
>> +            effective_url = url_search % {'query': query_param[2:],
>> +                                          'lang': lang}
>>         else:
>>             if has_web_scheme(url):
>>                 effective_url = url
>> --
>> 1.7.7.6
>>
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
>
> --
> .. manuq ..



-- 
.. manuq ..


More information about the Sugar-devel mailing list