Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale Problems with Date Range Display and It's Configuration #70

Open
gordonbanderson opened this issue Mar 13, 2014 · 2 comments
Open

Comments

@gordonbanderson
Copy link

I am currently upgrading a site from 2.4 to 3.1 and have run into an issue with the display of date ranges. The site is principally Thai, with a small English version alongside it.

There are 2 facets to this problem.

  1. There is no documentation regarding both how to configure the display of the date range, and the fact that it needs configured for locales other than de,nl,en. I added logging trace to CalendarDateTime::DateRange() and CalendarUtil::localize() as follows:
public static function localize($start, $end, $key) {
        global $customDateTemplates;
        if(is_array($customDateTemplates) && isset($customDateTemplates[$key])) {
            error_log('CAL: Checking for template '.$customDateTemplates[$key]);
            $template = $customDateTemplates[$key];
        }
        else {
            error_log('CAL: Getting calendar key from locale file');
            $template = _t("Calendar.$key"); 
        }

        error_log('CAL: Template='.$template);

        return str_replace(self::$format_character_placeholders, self::format_character_replacements($start,$end), $template);      
    }   

The value of $template was being logged as an empty string, hence my empty date range being displayed.

Searching for $customDateTemplates lead me to the event_calendar/_config.php

  1. In event_calendar/_config.php the values used for some of the constants in the commented out section are legacy, I suspect from the 2.4 version.
<?php

global $customDateTemplates;
$customDateTemplates = array(
/*
 You can modify the date display by assigning new date templates to any of the following
   date scenarios. Use the above date format keys.

'OneDay'            => '$StartMonthNameShort. $StartDayNumberShort, $StartYearFull'
'SameMonthSameYear' => '$StartMonthNameShort. $StartDayNumberShort - $EndDatNumberShort, $EndYearFull'
'DiffMonthSameYear' => '$StartMonthNameShort. $StartDayNumberShort - $EndMonthNameShort. $EndDayNumberShort, $EndYearFull'
'DiffMonthDiffYear' => '$StartMonthNameShort. $StartDayNumberShort, $StartYearFull - $EndMonthNameShort $EndDayNumberShort, $EndYearFull'

'OneDayHeader'          => '$StartMonthNameFull $StartDayNumberShort$StartDaySuffix, $StartYearFull'
'MonthHeader'           => '$StartMonthNameFull, $StartYearFull'
'YearHeader'                => '$StartYearFull'

*/
);

For example, EndYearFull is now EndYearLong, and EndDatNumberShort is a typo (should be EndDayNumberShort)

Whilst I see now that I can copy and then tweak a language file for displaying dates in Thai, I've tested this and it fixes the problem.

Can I suggest that a README file is added and information about how to fix this problem for the non catered for locales is added?

Cheers,

Gordon

@ss23
Copy link
Contributor

ss23 commented Mar 13, 2014

Sure thing. My preference is that you send a pull request for an updated readme though, as personally I don't have time at the moment, and this isn't particularly high priority for someone else to do it.

@gordonbanderson
Copy link
Author

Noted. I'll do it tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants