enable google translate to autodetect language with 'auto' fromlang.

This commit is contained in:
Daniel Folkinshteyn 2010-04-02 01:57:00 -04:00
parent f988736ca6
commit b8f8cec6f5
2 changed files with 4 additions and 1 deletions

View File

@ -76,7 +76,8 @@ class Language(registry.OnlySomeStrings):
'Tamil': 'ta', 'Tagalog': 'tl', 'Telugu': 'te',
'Thai': 'th', 'Tibetan': 'bo', 'Turkish': 'tr',
'Ukranian': 'uk', 'Urdu': 'ur', 'Uzbek': 'uz',
'Uighur': 'ug', 'Vietnamese': 'vi'}
'Uighur': 'ug', 'Vietnamese': 'vi',
'Detect language': 'auto'}
validStrings = ['lang_' + s for s in transLangs.values()]
validStrings.append('')
def normalize(self, s):

View File

@ -266,6 +266,8 @@ class Google(callbacks.PluginRegexp):
lang.transLangs.keys()))
else:
toLang = lang.normalize('lang_'+toLang)[5:]
if fromLang == 'auto':
fromLang = ''
opts['langpair'] = '%s|%s' % (fromLang, toLang)
fd = utils.web.getUrlFd('%s?%s' % (self._gtranslateUrl,
urllib.urlencode(opts)),