Page 2 of 2
Re: Date Picker localisation
Posted: Sun Jan 28, 2024 2:45 pm
by bn
Hendricus wrote: ↑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
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?
Hi Hendricus,
As I mentioned you have to put quotes around "monthNames".
Also if you use "Custom" as namesToUse then you have to set the dayNames in the order as if the week starts on Sunday
Code: Select all
put ("SU,MO,TU,WE,TH,FR,SA") into tDayNames
regardless of how you want you week want to start (Monday/Sunday). Otherwise Date Picker gets confused
This works with your example script (without 'translate')
Code: Select all
on mouseUp
// set the date picker
set the namesToUse of widget "Date Picker" to "Custom"
set the weekStartsOn of widget "Date Picker" to "Monday"
put ("SU,MO,TU,WE,TH,FR,SA") into tDayNames
set the dayNames of widget "Date Picker" to tDayNames
put toUpper(("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec")) into tMonthNames
set the "monthNames" of widget "Date Picker" to tMonthNames
end mouseUp
Kind regards
Bernd
Re: Date Picker localisation
Posted: Sun Jan 28, 2024 9:10 pm
by stam
Thanks Bernd,
As always, you are entirely correct and on closer inspection it's actually in the Dictionary for date picker > monthNames:
Use the monthNames property to set the displayed label to the name of the month, when the namesToUse property is set to "Custom"
even though no such thing is mentioned in the namesToUse entry...
It's a relief this is usable... but it remains annoying you cannot change the names in the property inspector (and AFAICS there is no 'namesToUse' property to get/set in the PI) and cannot get the names without an execution error (or were you able to solve that?)
S.
Re: Date Picker localisation
Posted: Sun Jan 28, 2024 9:33 pm
by bn
stam wrote: ↑Sun Jan 28, 2024 9:10 pm
It's a relief this is usable... but it remains annoying you cannot change the names in the property inspector (and AFAICS there is no 'namesToUse' property to get/set in the PI) and cannot get the names without an execution error (or were you able to solve that?)
Hi Stam,
I agree that the dictionary for "Date Picker" is lacking a lot of useful/necessary information.
and AFAICS there is no 'namesToUse' property to get/set in the PI
It is right there in the properties inspector where you can set 'English', 'System' and 'Custom'
And only in 'Custom' mode can you set the dayNames and monthNames.
cannot get the names without an execution error (or were you able to solve that?
I did not try to get them before but ran into problems getting them after your remark.
This seems ridiculous but the following worked for me:
Code: Select all
on mouseUp
put "monthNames" into tNames
put the tNames of widget "Date Picker"
end mouseUp
Kind regards
Bernd