Forum Archive

dialogs.date_dialog() Problem

Phuket2

@omz, not sure what's going on here. But if you call dialogs.date_dialog(), I am getting another language for the month names. I looked at the dialogs.py file, but I can't see the problem. Either, I missed it or it's deeper in your code. I am setup on Australian for my locale in settings

Phuket2

Oh, not a random Language, looks a little like Danish, but guessing it German. Would make it difficult for you to see it as a problem.

blmacbeth

@Phuket2 @omz I think I found the problem. After doing some digging into the DatePicker class in the ui module… just look:

>>> from objc_util import *
>>> import ui
>>> date_picker = ui.DatePicker(frame=(0,0,500,500))
>>> date_picker_pntr = ObjCInstance(date_picker)
>>> date_picker_pntr.locale()
<__NSCFLocale: <__NSCFLocale: 0x17698f70>>
>>> local = date_picker_pntr.locale()
>>> local.localeIdentifier()
<__NSCFString: de_DE> ## -> German (Germany)

I'm guessing it's German since @omz lives in Berlin. Just needs to change the locale.

B

EDIT: as an added bonus, here is a workaround until it gets fixed (I'm from the US, but you can look up your locale code)

#coding: utf-8
import ui
from objc_util import *

NSLocale = ObjCClass('NSLocale')
us_locale = NSLocale.alloc().initWithLocaleIdentifier_(ns('en_US'))

date_picker = ui.DatePicker(frame=(0,0,500,500))
date_picker_pntr = ObjCInstance(date_picker)
date_picker_pntr.setLocale_(us_locale)

date_picker.present('sheet')

Enjoy. Play around with removing the locale or changing it.

ccc

Pythonista's own locale module did not work last time I checked it out.

Phuket2

@blmacbeth , thanks for the info. It's was more just about reporting the problem. Just a tricky one to see when on the same local all the time I guess

Webmaster4o

This also affects form_dialog with a url field; the button that should say .com says .de.

omz

Thanks! I think I wouldn't have noticed this myself because a German date picker looks pretty normal to me...

The reason is a workaround for a bug in the iOS simulator – I'm faking a German locale because for some reason, the keyboard language can't be changed otherwise. This obviously should never have been in the version that's built for actual devices...