#6338 NORM -: French date format is not correct

Zarro Boogs per Child bugtracker at laptop.org
Thu Sep 18 00:26:10 EDT 2008


#6338: French date format is not correct
----------------------------+-----------------------------------------------
   Reporter:  pierre        |       Owner:  sayamindu                             
       Type:  defect        |      Status:  new                                   
   Priority:  normal        |   Milestone:                                        
  Component:  localization  |     Version:  Q2D16                                 
 Resolution:                |    Keywords:  french date format localization locale
Next_action:  review        |    Verified:  0                                     
  Blockedby:                |    Blocking:                                        
----------------------------+-----------------------------------------------
Changes (by pierre):

  * next_action:  => review
  * version:  Build 653 => Q2D16


Comment:

 After a lot of googling, I've found at least the reasons for such a
 behavior with Python programs. The full explanation is here:
 http://docs.python.org/lib/module-locale.html
 A program will not be locale aware as long you don't import the locale
 module and call setlocale(), even if your environment is set with a
 locale!

 So as the base class sugar.activity does not set the locale correctly
 according to the locale selected by the user in the control panel, you
 have to explicitly call setlocale() in your activity.

 A test program: change your locale to a non en_US in the control panel.

 {{{
 #!/usr/bin/env python
 import locale
 import os
 from datetime import datetime
 import time
 print "LANG=%s" % os.environ["LANG"]
 print "TZ=%s" % os.environ["TZ"]
 print datetime.now().strftime("datetime.now %A %x %c")
 print time.strftime("time %A %x %c")
 locale.setlocale(locale.LC_ALL, "")
 print datetime.now().strftime("datetime.now %A %x %c")
 print time.strftime("time %A %x %c")
 }}}

 Displays:
 {{{
 $ ./test.py
 LANG=fr_CA.utf8
 TZ=America/Montreal
 datetime.now Thursday 09/18/08 Thu Sep 18 00:15:24 2008
 time Thursday 09/18/08 Thu Sep 18 00:15:24 2008
 datetime.now jeudi 2008-09-18 jeu 18 sep 2008 00:15:24
 time jeudi 2008-09-18 jeu 18 sep 2008 00:15:24 EDT
 }}}

 Why the sugar.activity class does not set the locale? It already sets the
 messages according to the locale; why do half of the job?

-- 
Ticket URL: <http://dev.laptop.org/ticket/6338#comment:4>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list