Localize months names and day names for BP-Group Calendar

Hi!

I just installed and played a little with this plugin, and I found that after making a .po/.mo file for having it in my own language, month names and day names still in english language. (In fact, any of this is in the .po file generated from source).

I found another problem about locale settings too, the week starts on sunday for this calendar, but in my country the week starts on monday...

And for last... the time format when you edit or create an event in the calendar is am/pm format, but I'll need to have in 24h time format... it would be nice to have an option to choose between one format or another.

Please, I would appreciate a lot if these issues can be solved soon

By the way, instructions about how to make a temporary solution would be fine too.

Best regards.

  • Aaron

    month names and day names still in english language

    For starters, I really tried hard to localize this but it gets complicated as all the dates are generated by the PHP date() function. When coding it I assumed that using a different PHP local (a server config that is beyond the scope of this plugin) would change the language of the dates that the PHP date() function outputs. Looking into that now it seems date() doesn't support it. From PHP manual:

    To format dates in other languages, you should use the
    setlocale() and strftime()
    functions instead of <b>date()</b>.

    I will consider trying this next version, though not sure it is completely possible.

    And for last... the time format when you edit or create an event in the calendar is am/pm format, but I'll need to have in 24h time format... it would be nice to have an option to choose between one format or another.

    You can edit the format/order of date/time strings in your .po files. They will look something like 'm/d/Y g:ia'. So for 24 hour time change 'g:ia' to 'G:i'. Use this guide: http://php.net/manual/en/function.date.php

    I found another problem about locale settings too, the week starts on sunday for this calendar, but in my country the week starts on monday...

    Change the lines in calendar.class.php:
    var $week_start_on = FALSE;
    var $week_start = 7;// sunday

    To:
    var $week_start_on = TRUE;
    var $week_start = 1;// monday

  • analize

    Thank you very much for your fast reply Aaron

    I will consider trying this next version, though not sure it is completely possible.

    I hope so...

    You can edit the format/order of date/time strings in your .po files. They will look something like 'm/d/Y g:ia'. So for 24 hour time change 'g:ia' to 'G:i'. Use this guide: http://php.net/manual/en/function.date.php

    Yeah, I know that. And I did it, before posting. And works perfectly (except for the above problem).

    But I was talking about the hour in the form you use to create or edit an event... You put three list fields (hour, minute, am/pm) and in my country this should be only two list fields. One for hour ir 24h format and one for minutes.

    By the way... how about adding an optional field for end time? (so you can set start and end of an event).

    Change the lines in calendar.class.php:
    var $week_start_on = FALSE;
    var $week_start = 7;// sunday
    To:
    var $week_start_on = TRUE;
    var $week_start = 1;// monday

    When changing the var $week_start_on to TRUE I get this message in the calendar:

    The property week_start_on is replaced due to a bug present in version before 2.6. of this class! Use the property week_start instead!

    So I left it to FALSE, and the main calendar starts now in monday, but the calendar for date picker starts in sunday yet...

    I suppose that I should use this main file and the corresponding locale file instead?? http://dev.jqueryui.com/browser/tags/1.7.2/ui/minified/i18n

    Can you tell me please, if I can do an easy replace of the actual jquery-ui-1.7.2.custom.min.js for jquery-ui-i18n.min.js and ui.datepicker-es.min.js (the one I need for my language)??

    setlocale(LC_TIME, get_locale());

    This works to put the main calendar in my language THANKS!

    Again, thank you very much for your great support!

  • Aaron

    But I was talking about the hour in the form you use to create or edit an event

    You will have to modify the form fields yourself.

    Can you tell me please, if I can do an easy replace of the actual jquery-ui-1.7.2.custom.min.js for jquery-ui-i18n.min.js and ui.datepicker-es.min.js (the one I need for my language)??

    You can just change the calling javascript to set your locale:
    http://jqueryui.com/demos/datepicker/#localization

    For example this line in the javascript should change it to french and make monday first:
    jQuery.datepicker.setDefaults(jQuery.datepicker.regional['fr'], { firstDay: 1 });

  • analize

    Thank you very much Aaron!

    Finally with your help I found a pretty way to make datepicker use my locale settings:

    In the file bp-group-calendar.php below the line <script type="text/javascript" src="<?php echo $css_url; ?>datepicker/js/jquery-ui-1.7.2.custom.min.js"></script> I added the following line:

    <script type="text/javascript" src="<?php echo $css_url; ?>datepicker/js/ui.datepicker-es.min.js"></script>

    Where the ui.datepicker-es.min.js file is the Jquery UI file that sets the datepicker to use days and month in my language (you can find here files for all supported languages).

    Only need to change one more thing to that file, because originally firstDay is set to 0. After setting it to 1, now I have the datepicker fully localized

    I hope you can use this to add more locale support to the next version of the group calendar plugin.

    Best regards.