Skip to content

Commit

Permalink
Localise the format for the calendar formfield
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hunziker committed Sep 20, 2016
1 parent 6641a7a commit 7671410
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
21 changes: 16 additions & 5 deletions administrator/components/com_content/models/forms/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@
type="spacer" />

<field name="created" type="calendar" label="COM_CONTENT_FIELD_CREATED_LABEL"
description="COM_CONTENT_FIELD_CREATED_DESC" size="22"
format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
description="COM_CONTENT_FIELD_CREATED_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc" />

<field name="created_by" type="user"
label="COM_CONTENT_FIELD_CREATED_BY_LABEL" description="COM_CONTENT_FIELD_CREATED_BY_DESC" />
Expand All @@ -78,7 +81,11 @@

<field name="modified" type="calendar" class="readonly"
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_CONTENT_FIELD_MODIFIED_DESC"
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
translateformat="true"
showtime="true"
size="22"
readonly="true"
filter="user_utc" />

<field name="modified_by" type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
Expand All @@ -93,12 +100,16 @@

<field name="publish_up" type="calendar"
label="COM_CONTENT_FIELD_PUBLISH_UP_LABEL" description="COM_CONTENT_FIELD_PUBLISH_UP_DESC"
format="%Y-%m-%d %H:%M:%S" size="22"
translateformat="true"
showtime="true"
size="22"
filter="user_utc" />

<field name="publish_down" type="calendar"
label="COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL" description="COM_CONTENT_FIELD_PUBLISH_DOWN_DESC"
format="%Y-%m-%d %H:%M:%S" size="22"
translateformat="true"
showtime="true"
size="22"
filter="user_utc" />

<field name="version" type="text" class="readonly"
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,8 @@ DATE_FORMAT_LC3="d F Y"
DATE_FORMAT_LC4="Y-m-d"
DATE_FORMAT_LC5="Y-m-d H:i"
DATE_FORMAT_JS1="y-m-d"
DATE_FORMAT_CALENDAR_DATE="%Y-%m-%d"
DATE_FORMAT_CALENDAR_DATETIME="%Y-%m-%d %H:%M:%S"

; Months

Expand Down
2 changes: 2 additions & 0 deletions language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ DATE_FORMAT_LC3="d F Y"
DATE_FORMAT_LC4="Y-m-d"
DATE_FORMAT_LC5="Y-m-d H:i"
DATE_FORMAT_JS1="y-m-d"
DATE_FORMAT_CALENDAR_DATE="%Y-%m-%d"
DATE_FORMAT_CALENDAR_DATETIME="%Y-%m-%d %H:%M:%S"

; Months

Expand Down
20 changes: 19 additions & 1 deletion libraries/joomla/form/fields/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,25 @@ protected function getInput()
$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;

// Initialize some field attributes.
$format = $this->format;
$translateFormat = (string) $this->element['translateformat'];

if ($translateFormat && $translateFormat != 'false')
{
$showTime = (string) $this->element['showtime'];

if ($showTime && $showTime != 'false')
{
$format = JText::_('DATE_FORMAT_CALENDAR_DATETIME');
}
else
{
$format = JText::_('DATE_FORMAT_CALENDAR_DATE');
}
}
else
{
$format = $this->format;
}

// Build the attributes array.
$attributes = array();
Expand Down
3 changes: 2 additions & 1 deletion plugins/user/profile/profiles/profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
label="PLG_USER_PROFILE_FIELD_DOB_LABEL"
description="PLG_USER_PROFILE_FIELD_DOB_DESC"
info="PLG_USER_PROFILE_SPACER_DOB"
format="%Y-%m-%d"
translateformat="true"
showtime="false"
filter="server_utc"
/>

Expand Down

0 comments on commit 7671410

Please sign in to comment.