Date Picker localisation

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Hendricus
Posts: 7
Joined: Tue Aug 18, 2020 6:03 pm

Date Picker localisation

Post by Hendricus » Wed Jan 24, 2024 10:16 pm

I want to be able to change the Date Picker widget to match the language set by the i18n library using the following code

Code: Select all

// set the date picker
      set the namesToUse of widget "Date Picker" of group "Select Type Popup" of card "To Do" to "Custom"
      put translate("MO,TU,WE,TH,FR,SA,SU") into tDayNames
      set the dayNames of widget "Date Picker" of group "Select Type Popup" of card "To Do" to tDayNames
      put toUpper(translate("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec")) into tMonthNames
      set the monthNames of widget "Date Picker" of group "Select Type Popup" of card "To Do" to tMonthNames
Unfortunately, the property 'the monthNames' as described in the Dictionary for the widget is also a core Livecode function and is raised as a compilation error in the Livecode IDE, saying that "token is not a property". Does anyone know what the correct property for changing the month names of the Date Picker widget must be?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Date Picker localisation

Post by Klaus » Thu Jan 25, 2024 1:47 pm

Hi Hendricus,

sorry, no solutuon for your problem, but you really should report this bug here:
https://quality.livecode.com
If not reported this will never get fixed.

Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Date Picker localisation

Post by dunbarx » Thu Jan 25, 2024 2:39 pm

Hendricus.

After reporting the conflict, as it is not really a bug in the usual sense, you will have to roll your own "month names" function. At least then it will not conflict with a native LC function. I do not use widgets, but assume this is simple to do.

I think.

Craig

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Date Picker localisation

Post by Klaus » Thu Jan 25, 2024 2:46 pm

dunbarx wrote:
Thu Jan 25, 2024 2:39 pm
Hendricus.

After reporting the conflict, as it is not really a bug in the usual sense, you will have to roll your own "month names" function. At least then it will not conflict with a native LC function. I do not use widgets, but assume this is simple to do.

I think.

Craig
No, it isn't!

Code: Select all

set the monthNames of widget "Date Picker" of group "Select Type Popup" of card "To Do" to tMonthNames
"the monthnames" is a (custom?) property of that widget so you cannot work around this.
Congratulations Livecode for this very clever "catch 22", you shot your own foot with a .357 Magnum! :(

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Date Picker localisation

Post by dunbarx » Thu Jan 25, 2024 8:47 pm

Klaus.

I know. That is why I mentioned he would have to roll his own. But perhaps you meant that there is NO way to do this, due to the "closed" nature of a widget object type?

Craig

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Date Picker localisation

Post by Klaus » Thu Jan 25, 2024 9:37 pm

I meant that there is no workaround for THIS widget.

And that this is more than embarrassing for Livecode!

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Date Picker localisation

Post by stam » Fri Jan 26, 2024 1:53 am

There is funkiness here...

Code: Select all

get the monthNames of widget "date picker"
generates a runtime error
Execution error: Chunk: source is not a container
You can't even set the month names manually in the property inspector...

Clearly incorrect behaviour, has anyone bug-reported this?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Date Picker localisation

Post by Klaus » Fri Jan 26, 2024 1:39 pm

stam wrote:
Fri Jan 26, 2024 1:53 am
...
Clearly incorrect behaviour, has anyone bug-reported this?
Just checked the "quality center", no report so far.

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: Date Picker localisation

Post by bobcole » Fri Jan 26, 2024 6:08 pm

The monthNames used in the Calendar widget's header can be changed in the Property Inspector.
They are 3 character name by default but can be changed in the PI. That worked.

I tried to access the monthNames of the widget by script (as described in the dictionary) but that didn't work.
I tried to access the dayNames of the widget by script; that worked.

This should be fixed. Also, I suggest a unique name (not monthNames) for the Calendar widget.
Bob

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Date Picker localisation

Post by stam » Fri Jan 26, 2024 6:45 pm

Hi Bob,

I did not share your luck with changing monthNames in the PI.

I wonder if that's because you may have used the Calendar extension (an older extension by LC) rather than then new Date Picker extension?? I ask because the monthNames in datePicker are full words, not 3 letters, as is the case with the Calendar extension.
calendar vs date picker.jpg

In the Date Picker extension's property inspector, any change I try to make in the PI is reset when I exit the field.
what's more interesting is that the PI presents these as comma-separated list, whereas if you type in the messageBox

Code: Select all

put the monthNames of widget "date picker"
you get a return-delimited list, which suggest the PI's type should be enum, not text/list.
And as mentioned, if you script this in a button you get get an execution error...

Seems like a hot mess?

Stam

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Date Picker localisation

Post by stam » Fri Jan 26, 2024 7:10 pm

I submitted a bug report here: https://quality.livecode.com/show_bug.cgi?id=24480
If you're interested, add your emails to be notified of it's progress.

Stam

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Date Picker localisation

Post by Klaus » Fri Jan 26, 2024 7:44 pm

Thank you!

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: Date Picker localisation

Post by bobcole » Sat Jan 27, 2024 2:12 am

Yes, I used the Calendar widget.
I wasn't aware there was another: Date Picker.
Sorry,
Bob

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Date Picker localisation

Post by stam » Sat Jan 27, 2024 2:14 am

I think it was released with the summer megabundle but might be mistaken. A lot of widgets in that were problematic….

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Date Picker localisation

Post by bn » Sun Jan 28, 2024 1:50 pm

It turns out that you can only set the monthNames if the "namesToUse" are set to "Custom"

this works for me with widget DatePicker

Code: Select all

on mouseUp pButtonNumber
   set the namesToUse of widget 1 to "Custom"
   set the weekStartsOn of widget 1 to "Sunday"
   set the "MonthNames" of widget 1 to "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC"
   set the weekStartsOn of widget 1 to "Sunday"
   set the dayNames of widget 1 to "su,mo,tu,wed,thu,fr,sa"
end mouseUp
Note: namesToUse "Custom" is case sensitive, upper "C" required, also note that "monthNames" are quoted, not case sensitive.


Kind regards
Bernd

Post Reply

Return to “Talking LiveCode”