← Back to team overview

openerp-dutch team mailing list archive

[Bug 510023] Re: "WARNING:translate:Unable to set locale" error on Ubuntu 9.10/CentOS 5.4 x64

 

** Changed in: openobject-client
       Status: New => Confirmed

-- 
"WARNING:translate:Unable to set locale" error on Ubuntu 9.10/CentOS 5.4 x64
https://bugs.launchpad.net/bugs/510023
You received this bug notification because you are a member of OpenERP
Dutch Team - Nederland, which is the registrant for OpenERP Dutch
Lokalisatie Project - Nederland.

Status in OpenERP-Dutch-localisation: Fix Committed
Status in OpenObject GTK Client: Confirmed

Bug description:
On both Ubuntu 9.10 and CentOS 5.4 x64 the OpenERP client will incorrectly load the locale (in this case, nl_NL.UTF-8) upon login into a database with the error
WARNING:translate:Unable to set locale nl_NL.UTF-8

In translate.py the following line causes this:
locale.setlocale(locale.LC_ALL, lang_enc

removing the try block reveals the following stack trace:
Traceback (most recent call last):
  File "./openerp-client.py", line 135, in <module>
    win.sig_login()
  File "/usr/local/lib/python2.6/dist-packages/openerp-client/modules/gui/main.py", line 1023, in sig_login
    log_response = rpc.session.login(*res)
  File "/usr/local/lib/python2.6/dist-packages/openerp-client/rpc.py", line 233, in login
    self.context_reload()
  File "/usr/local/lib/python2.6/dist-packages/openerp-client/rpc.py", line 290, in context_reload
    translate.setlang(self.context['lang'])
  File "/usr/local/lib/python2.6/dist-packages/openerp-client/translate.py", line 184, in setlang
    locale.setlocale(locale.LC_ALL,lang_enc)    
  File "/usr/lib/python2.6/locale.py", line 514, in setlocale
    locale = normalize(_build_localename(locale))
  File "/usr/lib/python2.6/locale.py", line 422, in _build_localename
    language, encoding = localetuple
ValueError: too many values to unpack

Upon further analysis, it turns out that 'type(lang)' is not <str>, but <unicode>. Converting lang to str with str(lang) works around the problem, but I'm guessing it really shouldn't be a unicode:

---
if lang:
   if type(lang) is not type(''):
      lang = str(lang)
---