DateTime data type format and localization

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

DateTime data type format and localization

Post by jalfonso » 2020-05-11 16:55

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!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: DateTime data type format and localization

Post by pbottcher » 2020-05-16 17:32

Hi,

you can try

moment.updateLocale('en', {week: {dow: 1}});
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-24 17:44

Hello.
Thanks for the answer

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: DateTime data type format and localization

Post by pbottcher » 2020-05-25 20:22

Did you try it?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 09:21

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

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 10:03

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!

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 10:58

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

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 11:32

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...
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 11:35

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 7249 times
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 11:37

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 7249 times

I hope this will help you configuring your datetimepickers.

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 12:45

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

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 12:59

Firefox cache cleaned
apache restarted
tested with chromium

same behavior

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 13:00

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 7233 times
chrome_VDlsQpMXnd.png
chrome_VDlsQpMXnd.png (7.02 KiB) Viewed 7233 times
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 14:52

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

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 14:56

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?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 15:10

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'
});

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 15:32

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 7201 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 7201 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:
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 16:05

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.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 16:23

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.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 16:42

It works!

Image

Modifying :

Code: Select all

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

Thanks!
Last edited by jalfonso on 2020-05-26 16:47, edited 1 time in total.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: DateTime data type format and localization

Post by jsetzer » 2020-05-26 16:46

:? 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
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jalfonso
Posts: 26
Joined: 2020-05-05 17:36
Location: Canary Islands

Re: DateTime data type format and localization

Post by jalfonso » 2020-05-26 16:51

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

Post Reply