Page 1 of 1

DateTime data type format and localization

Posted: 2020-05-11 16:55
by jalfonso
Hello to everybody
Any possible way to change the format of the form for the data type "DateTime", weeks starting on Monday and localization?. I've noticed that the "date" type is adapted to another language, but DateTime remains in English, with the week starting on Sunday

Thanks!

Re: DateTime data type format and localization

Posted: 2020-05-16 17:32
by pbottcher
Hi,

you can try

moment.updateLocale('en', {week: {dow: 1}});

Re: DateTime data type format and localization

Posted: 2020-05-24 17:44
by jalfonso
Hello.
Thanks for the answer

Should I put it in the [tablename]-dv.js file in the hooks directory?

Re: DateTime data type format and localization

Posted: 2020-05-25 20:22
by pbottcher
Did you try it?

Re: DateTime data type format and localization

Posted: 2020-05-26 09:21
by jalfonso
no idea what to do. I put the line indicated in the [tablename]-dv.js file and nothing has changed
I've been looking in the folder:

/resources/bootstrap-datetimepicker
and
https://malot.fr/bootstrap-datetimepicker/

but the files are not understandable to me

Any ideas?
Thank you

Re: DateTime data type format and localization

Posted: 2020-05-26 10:03
by jalfonso
I don't know if I have explained myself well (English is not my language). I need the Datetime widget in Spanish with the week starting on Monday

Image

I'm a real newbie with no knowledge of bootstrap, javascript or css

Thank you!

Re: DateTime data type format and localization

Posted: 2020-05-26 10:58
by jalfonso
I added the line

<script src="hooks/AppGiniHelper.min.js"></script>

to header-extras.php

and by adding the line :

moment.updateLocale('en', {week: {dow: 1}});

to [tablename]-dv.js

I got the week to start on Monday.

If I change it to :

moment.updateLocale('es', {week: {dow: 1}});

it continues in English and the start of the week returns to Sunday

I understand this is because there is no translation of the bootstrap-datetimepicker into languages other than English. On the other hand, it doesn't seem to work if I don't have the bizzworxx javascript helper installed. Would you know where I can add the month and day names in Spanish to add them to this widget?

Thank you

Re: DateTime data type format and localization

Posted: 2020-05-26 11:32
by jsetzer
For me it is getting confusing here and I'd like to clean up a bit:
  • Just including AppGiniHelper.min.js does not change any default behaviour or options on standard AppGini datetime fields.
  • moment.js get's included by default (actually it is moment-with-locales.min.js)
    and there is a spanish localization included
  • Also bootstrap-timepicker and bootstrap-datetimepicker get included by default
I am going to post two examples for switching to spanish 'es' and changing first day of week from sunday to monday in a minute.

Stay tuned...

Re: DateTime data type format and localization

Posted: 2020-05-26 11:35
by jsetzer
Name of field is "datetime".
Set locale to "es" (=spanish)
Set first day of week = 0 (Sunday – domingo)

Code

Code: Select all

// file: TABLENAME-dv.js
moment.updateLocale('es', {week: {dow: 0}});

$j("#datetime").parent().datetimepicker({
    locale: 'es'
});
Result
chrome_k41wgP3spJ.png
chrome_k41wgP3spJ.png (12.71 KiB) Viewed 9988 times

Re: DateTime data type format and localization

Posted: 2020-05-26 11:37
by jsetzer
Name of field is "datetime".
Set locale to "es" (=spanish)
Set first day of week = 1 (Monday – lunes)

Code

Code: Select all

// file: TABLENAME-dv.js
moment.updateLocale('es', {week: {dow: 1}});

$j("#datetime").parent().datetimepicker({
    locale: 'es'
});
Result
vWA4iKqBgY.png
vWA4iKqBgY.png (12.5 KiB) Viewed 9988 times

I hope this will help you configuring your datetimepickers.

Regards,
Jan

Re: DateTime data type format and localization

Posted: 2020-05-26 12:45
by jalfonso
Hello. Thank you for the answer and the clarifications

The same behavior I told you about before:

moment.updateLocale('es', {week: {dow: 1}});
$j("#datetime").parent().datetimepicker({
locale: 'es'
});
English language, first day of the week Sunday


moment.updateLocale('en', {week: {dow: 1}});
$j("#datetime").parent().datetimepicker({
locale: 'en'
});
English language, first day of the week Monday


Somehow, when I change the locale to 'es', it stays in English and ignores the 'dow' parameter (or the entire code). In case anyone is wondering, I haven't modified any other files. I'm working with the default appgini generated code

Re: DateTime data type format and localization

Posted: 2020-05-26 12:59
by jalfonso
Firefox cache cleaned
apache restarted
tested with chromium

same behavior

Re: DateTime data type format and localization

Posted: 2020-05-26 13:00
by jsetzer
Can you please check if there are any warnings in the console tab of your browser's developer tools, and if there are, please post them here (as code please for better readability).

chrome_sqJMCQUBDy.png
chrome_sqJMCQUBDy.png (6.89 KiB) Viewed 9972 times
chrome_VDlsQpMXnd.png
chrome_VDlsQpMXnd.png (7.02 KiB) Viewed 9972 times

Re: DateTime data type format and localization

Posted: 2020-05-26 14:52
by jalfonso
No errors. I've forced an error to check that it's detected. I also tried the options provided by the stackoverflow thread:

https://stackoverflow.com/questions/244 ... y#31492457

No changes

Re: DateTime data type format and localization

Posted: 2020-05-26 14:56
by jsetzer
jsetzer wrote:
2020-05-26 13:00
Can you please check if there are any warnings in the console tab of your browser's developer tools
No errors.
What about warnings?

Re: DateTime data type format and localization

Posted: 2020-05-26 15:10
by jalfonso

Code: Select all

This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. entradasalida_view.php

Code: Select all

Use of Mutation Events is deprecated. Use MutationObserver instead. jquery-1.12.4.min.js:3:9646
These warnings with the locale in Spanish on file entradasalida-dv.js :

Code: Select all

moment.updateLocale('es', {week: {dow: 1}});

$j("#datetime").parent().datetimepicker({
    locale: 'es'
});

Re: DateTime data type format and localization

Posted: 2020-05-26 15:32
by jsetzer
Three last ideas:
  1. Try with "es-do" instead of "es"
  2. Try with "de" instead of "es" (just so see if there is any effect at all)
  3. In dev-console tab "Sources", tab "Page", under localhost / your app directory, find resources, moment, moment-with-locales.min.js and open the contents (right-click, open in new tab).
    chrome_CS38U8lMqT.png
    chrome_CS38U8lMqT.png (37.01 KiB) Viewed 9940 times
    In the source-code-view tab, search for "es" (CTRL+F). There should be at least one match for "es" like this one here:
    chrome_nSUQMF77Hn.png
    chrome_nSUQMF77Hn.png (17.83 KiB) Viewed 9940 times
    You can also search for "es-do". There should be one match, too.
    If there is no "es" and no"es-do", there may be a problem with wrong moment library version. But honestly, this would be very, very weird if you are using standard AppGini >5.7 generated code. I cannot believe "es" was missing.
No more ideas. :cry:

Re: DateTime data type format and localization

Posted: 2020-05-26 16:05
by jalfonso
With other languages, for example 'de' or 'es-do', the same behaviour. I've proven that they exist:

definelocale("es"...
definelocale("es-do"...

in the file "moment-with-locales.min.js" (using appgini 5.82)

Well, at least we got the week started on a Monday

Thank you very much for your time, Mr. Setzer.

Re: DateTime data type format and localization

Posted: 2020-05-26 16:23
by jsetzer
One more idea:

In ./language.php you could check the value of

Code: Select all

$Translation['datetimepicker locale'] = 'de';
In defaultLang.php the default value should be set to 'en' and then, including language.php should overwrite 'en' by 'es' (in your case).

Default value configured in ./defaultLang.php:

Code: Select all

$Translation['datetimepicker locale'] = 'en';
Give it a try with 'es' in language.php and remove the javascript at first. Then try the javascript command by command and always reload your browser with clearing cache.

Re: DateTime data type format and localization

Posted: 2020-05-26 16:42
by jalfonso
It works!

Image

Modifying :

Code: Select all

$Translation['datetimepicker locale'] = 'es';
in file language.php (and deleting javascript code in TABLE-dv.js)

Thanks!

Re: DateTime data type format and localization

Posted: 2020-05-26 16:46
by jsetzer
:? I'm wondering, what was inside language.php before and where did you get that file from? It should be 'es' by default in spanish language file.

Anyway, I'm happy we got it! :D

Best,
Jan

Re: DateTime data type format and localization

Posted: 2020-05-26 16:51
by jalfonso
I think it's an error in the language.php file downloaded from the web. You see, the whole file is translated but the line referring to "datetimepicker locale" is "en"

https://cdn.bigprof.com/appgini-desktop ... panish.zip

Thank you again