Smf2.1: Month name is not displayed correctly in Week beginning in other language

Created on 26 Dec 2018  路  11Comments  路  Source: SimpleMachines/SMF2.1

Description

Month name is not displayed correctly in start of week in other language.

Steps to reproduce

  1. German Language
  2. 2.

Environment (complete as necessary)

  • Version/Git revision: Pull Request 5620
  • Database Type: MySQL
  • Database Version: 5.6.42-log
  • PHP Version: 7.1.22

Additional information/references

wochenbeginn

Language

All 11 comments

The issue is here:
https://github.com/SimpleMachines/SMF2.1/blob/416b859bea7570953fa4aae570e1c94736774f68/Sources/Subs-Calendar.php#L593-L598
597 generate the text,
i got no idea how to fix this in a nice way.

Maybe with something like this?

$txt['months_titles'][$calendar_data['current_month']]

The issue is here:
SMF2.1/Sources/Subs-Calendar.php

Lines 593 to 598 in 416b859

// An adjustment value to apply to all calculated week numbers.
if (!empty($calendarOptions['show_week_num']))
{
$timestamp = mktime(0, 0, 0, $month, $day, $year);
$calendarGrid['week_title'] = sprintf($txt['calendar_week_beginning'], date('F', $timestamp), date('j', $timestamp), date('Y', $timestamp));
}

597 generate the text,
i got no idea how to fix this in a nice way.

@albertlast , you were faster. Had overlooked your answer.

Maybe:

$calendarGrid['week_title'] = sprintf($txt['calendar_week_beginning'], $txt['months'][date('n', $timestamp)], date('j', $timestamp), date('Y', $timestamp)); 

Thats works.

If only setlocale() were actually reliable for this...

Just replace
date('F', $timestamp)
with
$txt['months'][date('n', $timestamp)]

Maybe:

$calendarGrid['week_title'] = sprintf($txt['calendar_week_beginning'], $txt['months'][date('n', $timestamp)], date('j', $timestamp), date('Y', $timestamp)); 

Thats works.

I had already suggested this in my previous post

Er, how does that commit fix this issue?

Welp, sorry. Apparently wrong commit. Anyway it was fixed in #5611 as we can see in:
https://github.com/SimpleMachines/SMF2.1/blob/6ba1e53c0b65edb202fa17b9dc0088f610fdbfd8/Sources/Subs-Calendar.php#L613

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dzonny picture Dzonny  路  9Comments

VBGAMER45 picture VBGAMER45  路  4Comments

colinschoen picture colinschoen  路  9Comments

XinYenFon picture XinYenFon  路  11Comments

replikacep picture replikacep  路  4Comments