"WARNING:translate:Unable to set locale" error on Ubuntu 9.10/CentOS 5.4 x64

Bug #510023 reported by The Loeki
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo GTK Client (MOVED TO GITHUB)
Invalid
Undecided
Unassigned
OpenERP Dutch Lokalisatie Project - Nederland
Fix Committed
Medium
The Loeki

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)
---

The Loeki (the-loeki)
Changed in openerp-dutch-lok:
status: New → Fix Committed
importance: Undecided → Low
importance: Low → Medium
assignee: nobody → The Loeki (the-loeki)
tfr (Openerp) (tfr)
Changed in openobject-client:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → OpenERP sa GTK client R&D (openerp-dev-gtk)
status: Confirmed → New
Changed in openobject-client:
status: New → Confirmed
tfr (Openerp) (tfr)
Changed in openobject-client:
milestone: none → 6.0-rc2
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Loeki,

If you try to set locally the other locale the the default one you will have this exception
When you execute the following command to set locale on your python prompt you will get the original Exception . i.e
locale.setlocale(locale.LC_ALL,'nl_NL')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/locale.py", line 513, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

So,
The gtk tries to set your default locale to nl_NL by locale.setlocale() but your machine does not have the entry in its locale file. ie you need to explicitly make an entry of the locale needed by following ways:
1: using the command:
                      sudo locale-gen 'nl_NL.UTF-8'
2: manually edit the file
                      /var/lib/locales/supported.d/local and make the entry of the locale you need.

Then when you restart the gtk . It will easily set the locale.

Thanks,

Revision history for this message
tfr (Openerp) (tfr) wrote :

Incomplete since we are waiting for an answer
And this issue old on not recent linux distribution

Changed in openobject-client:
status: Confirmed → Incomplete
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Loeki,

A different approach to set your locales..

1: Go to :/var/lib/locales/supported.d/
Note: you need to change the permission of locale file
2: edit locale file
3: paste on new line nl_NL.UTF-8 UTF-8
4:click save and go to the terminal
5:execute sudo dpkg-reconfigure locales
6:restart your gtk client.

As this is a configuration issue I would close this bug as invalid.

Regards,

Changed in openobject-client:
status: Incomplete → Invalid
assignee: OpenERP sa GTK client R&D (openerp-dev-gtk) → nobody
importance: Low → Undecided
milestone: 6.0-rc2 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.