1 (edited by 2013-01-12 04:44:59)

Topic: Changing Language of Dates, etc

I wanted to know how can I change the {date} to another language? I'm able to change the date of "Posted on" through the templates, but can't seem to change it on the comments section.
I saw earlier a post about a hack, but it seems that with the updated version, some files have been renamed and change.

Re: Changing Language of Dates, etc

In Options > Edit templates > 2 Template variables pay attention what you can publish instead of  {date} in other format, i.e {month|Jan,Feb,...,Dec} or {weekday} etc.

Best regards,
CN Support team

3 (edited by 2013-05-16 09:12:57)

Re: Changing Language of Dates, etc

In Options > Edit templates > 2 Template variables pay attention what you can publish instead of  {date} in other format, i.e {month|Jan,Feb,...,Dec} or {weekday} etc.

I use:
Geschreven door {author-name}. Online op {day} {month|januari,februari,maart,april,mei,juni,juli,augustus,september,oktober,nov
ember,december} {year} om {hours}:{minite} uur.

When i use {weekday|maandag,dinsdag,...,zondag} weekday is not translated, the whole line became visible. With month it works fine.

4 (edited by 2013-05-18 23:04:24)

Re: Changing Language of Dates, etc

Yes, currently (1.5.3), only month names are translatable. But if you're not scared to open a file and change some lines, we can add translatable weekdays https://cutephp.com/forum/style_emoticons/default/wink.gif

Open /core/core.php and find: (line 1200 - 1215)
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>function embedateformat($timestamp, $output)
{
    // Months
    if ( preg_match_all('~{month(\|.*?)?}~i', $output, $monthd, PREG_SET_ORDER) )
    {
        foreach ($monthd as $v)
            if (empty($v[1])) $output = str_replace($v[0], date('F', $timestamp), $output);
            else
            {
                $monthlist = spsep(substr($v[1], 1));
                $output = str_replace($v[0], $monthlist[date('n', $timestamp)-1], $output);
            }
    }

    // Others parameters
    $output     = str_replace('{weekday}', date('l', $timestamp), $output);</div>

Remove the last line (with {weekday} in it)

Below. add the following code (where you removed the line):
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>    // Weekdays
    if ( preg_match_all('~{weekday(\|.*?)?}~i', $output, $weekd, PREG_SET_ORDER) )
    {
        foreach ($weekd as $v)
            if (empty($v[1])) $output = str_replace($v[0], date('l', $timestamp), $output);
            else
            {
                $weeklist = spsep(substr($v[1], 1));
                $output = str_replace($v[0], $weeklist[date('w', $timestamp)], $output);
            }
    }</div>

I tested it, works like a charm.

Warning: The week starts with Sunday! So you would have something like
{weekday|zondag,maandag,dinsdag,woensdag,donderdag,vrijdag,zaterdag}

This will accept both {weekday} or {weekday|zondag,...}. Veel geluk!

5 (edited by 2013-05-19 06:56:23)

Re: Changing Language of Dates, etc

'I tested it, works like a charm.'

I'm not a PHP writer but i'm not afraid changing lines...so i did...
Thanks...!!!! Here it also works like a charm.
https://cutephp.com/forum/style_emoticons/default/smile.gif

@support-team:
I use 2 templates, one based on the default template and the other on template headlines.
Via edit template:
In the sections active story and full story i have more options (variables) for the date to use.
In the comment section i only can use {date}.
Are there plans to expand the variables for this section, so i can use the same variables as in the other 2 sections?

Re: Changing Language of Dates, etc

There are already plans for extension of available names. We're working for the next version of Cutenews.

Best regards,
CN Support team