Prevent translating date format while compiling #626

Closed
opened 2020-12-21 12:06:21 +00:00 by dormasta · 2 comments
dormasta commented 2020-12-21 12:06:21 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Output some date in site view
echo HtmlHelper::date($DateString, Text::_('DATE_FORMAT_LC3'));
Compile

Expected result

DATE_FORMAT_LC3

Actual result

COM_COMPONENT_DATE_FORMAT_LCTHREE

System information (as much as possible)

  • OS Name & Version: 10.15.7
  • MySql Version: 5.7.26
  • Apache Version:
  • PHP Version: 7.4.2
  • Joomla Version: 3.9.23
  • JCB Version: 2.12.2
  • Browser: safari, chrome, Firefox

Additional comments

### Steps to reproduce the issue Output some date in site view echo HtmlHelper::date($DateString, Text::_('DATE_FORMAT_LC3')); Compile ### Expected result DATE_FORMAT_LC3 ### Actual result COM_COMPONENT_DATE_FORMAT_LCTHREE ### System information (as much as possible) - OS Name & Version: 10.15.7 - MySql Version: 5.7.26 - Apache Version: - PHP Version: 7.4.2 - Joomla Version: 3.9.23 - JCB Version: 2.12.2 - Browser: safari, chrome, Firefox ### Additional comments

Okays so the code that already is in JCB that should have work is found here on line 6499 in the Get class.

Our problem is that it removes numbers and so since DATE_FORMAT_LC3 has a 3 in it, it gets converted to DATE_FORMAT_LCTHREE and therefore fails the test...

Can you try the following as a fix?

public function setLang($string)
{
	// this is there to insure we don't break already added Language strings
	if (ComponentbuilderHelper::safeString($string, 'U', '_', false, false) === $string)
	{
		return false;
	}
	// build lang key
	$keyLang = $this->langPrefix . '_' . ComponentbuilderHelper::safeString(
			$string, 'U'
		);
	// set the language string
	$this->setLangContent($this->lang, $keyLang, $string);

	return $keyLang;
}

Let me know if this works for you... so I can update the core.

Okays so the code that already is in JCB that should have work is found here on [line 6499](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/helpers/compiler/a_Get.php#L6499) in the Get class. Our problem is that [it removes numbers](https://github.com/vdm-io/Joomla-Component-Builder/blob/664c2d5f2a92171d32c6c84d7dfbba9fba284069/admin/helpers/componentbuilder.php#L7436) and so since `DATE_FORMAT_LC3` has a 3 in it, it gets converted to `DATE_FORMAT_LCTHREE` and therefore fails the test... Can you try the following as a fix? ```php public function setLang($string) { // this is there to insure we don't break already added Language strings if (ComponentbuilderHelper::safeString($string, 'U', '_', false, false) === $string) { return false; } // build lang key $keyLang = $this->langPrefix . '_' . ComponentbuilderHelper::safeString( $string, 'U' ); // set the language string $this->setLangContent($this->lang, $keyLang, $string); return $keyLang; } ``` Let me know if this works for you... so I can update the core.
dormasta commented 2020-12-28 13:01:29 +00:00 (Migrated from github.com)

HI Llewellyn,

absolutely sorry for the delay, but I somehow crashed my component and it took me some time to find the reason.
Anyway, you fix works like a charm. Thank you very much.

Cheers,
DTA

HI Llewellyn, absolutely sorry for the delay, but I somehow crashed my component and it took me some time to find the reason. Anyway, you fix works like a charm. Thank you very much. Cheers, DTA
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#626
No description provided.