? Pending

User tests: Successful: Unsuccessful:

avatar GeraintEdwards
GeraintEdwards
9 Nov 2018

Pull Request for Issue # .

Summary of Changes

Change ActionlogsHelper to load translation files for packages from /language instead of administrator/language

Testing Instructions

Install a package with a translated package name e.g. YourSites (from https://www.yoursites.net) or JCE (from https://www.joomlacontenteditor.net/) and then view the action logs.

The package name is not translated

untranslatedoackagename

The reason is that package language files are installed in the frontend and not the backend language folder but action logs tries to load these from the backend

wronglanguagefilefolders

With the change in this PR action logs load the language files from the frontend and the package name is translated properly

packagenametranslated

Expected result

Package name should be translated

Actual result

Package name is not translated

Documentation Changes Required

avatar GeraintEdwards GeraintEdwards - open - 9 Nov 2018
avatar GeraintEdwards GeraintEdwards - change - 9 Nov 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 9 Nov 2018
Category Administration
avatar infograf768
infograf768 - comment - 9 Nov 2018

Adding the pkg is a good idea. That file needs more to cope with other situations.
Please see #22816 (comment)
I never got a reply there.

avatar mbabker
mbabker - comment - 9 Nov 2018

Adding the pkg is a good idea. That file needs more to cope with other situations.
Please see #22816 (comment)
I never got a reply there.

Sorry, been busy. @infograf768 send it up as a PR.

avatar GeraintEdwards
GeraintEdwards - comment - 9 Nov 2018

I'll have a look at the other issue - this PR deals with one specific situation, the translation of package names.

The issue arises because the Installer\parseLanguages method takes a $cid argument.

  • Libraries, packages and files don't pass a $cid so have their language files stored in the frontend.
  • Plugins pass $cid = 1;
  • Templates and modules pass the relevant client id.
  • Components do both

So strictly speaking my PR should be amended so that the function reads more like:
`public static function loadTranslationFiles($extension)
{
static $cache = array();
$extension = strtolower($extension);

	if (isset($cache[$extension]))
	{
		return;
	}

	$lang   = JFactory::getLanguage();

	switch (substr($extension, 0, 3))
	{
		case 'com':
		default:
			$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
			break;

		case 'lib':
			$source = JPATH_LIBRARIES . '/' . substr($extension, 4);
			break;

		case 'mod':
			$source = JPATH_SITE . '/modules/' . $extension;
			break;

		case 'plg':
			$parts = explode('_', $extension, 3);
			$source = JPATH_PLUGINS . '/' . $parts[1] . '/' . $parts[2];
			break;

		case 'tpl':
			$source = JPATH_BASE . '/templates/' . substr($extension, 4);
			break;

	}

	switch (substr($extension, 0, 3))
	{
		case 'com':
		case 'mod':
		case 'tpl':
		default:
			// Language files can be in frontend or backend only - load priority is extension specific, followed by backend then frontend
			$lang->load($extension, $source, null, false, true)
			|| $lang->load($extension, JPATH_ADMINISTRATOR, null, false, true)
			|| $lang->load($extension, JPATH_SITE, null, false, true);

			if (!$lang->hasKey(strtoupper($extension)))
			{
				$lang->load($extension . '.sys', $source, null, false, true)
				|| $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true)
				|| $lang->load($extension . '.sys', JPATH_SITE, null, false, true);
			}

			break;

		case 'plg':
			// Language files in backend only
			$lang->load($extension, $source, null, false, true)
			|| $lang->load($extension, JPATH_ADMINISTRATOR, null, false, true);

			if (!$lang->hasKey(strtoupper($extension)))
			{
				$lang->load($extension . '.sys', $source, null, false, true)
				|| $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true);
			}

			break;

		case 'lib':
		case 'pkg':
			// Language files in frontend only
			$lang->load($extension, $source, null, false, true)
			|| $lang->load($extension, JPATH_SITE, null, false, true);

			if (!$lang->hasKey(strtoupper($extension)))
			{
				$lang->load($extension . '.sys', $source, null, false, true)
				|| $lang->load($extension . '.sys', JPATH_SITE, null, false, true);
			}
			
		break;

	}

	$cache[$extension] = true;
}`

which is, in essence, a variation on your code. So if you can add the package handling into your PR I can test your PR and we can then close this one.

avatar infograf768
infograf768 - comment - 9 Nov 2018

@GeraintEdwards
Please complete your PR with the right code. More simple. :)

avatar alikon
alikon - comment - 9 Nov 2018

I have tested this item successfully on e775ecf


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22976.

avatar alikon alikon - test_item - 9 Nov 2018 - Tested successfully
avatar alikon
alikon - comment - 9 Nov 2018

p.s
@infograf768 for #22816 (comment)

let's continue the issue there.... this is a simple good fix for now ...

avatar infograf768
infograf768 - comment - 10 Nov 2018

@alikon
#22816 is not a PR, just an issue.
Or we create a new PR including the pkg code added here as @GeraintEdwards suggests, or we do complete this one here.

avatar GeraintEdwards
GeraintEdwards - comment - 12 Nov 2018

@infograf768 As @alikon says - this current PR is very simple and solves a specific issue.

I'll open a new PR with my second code block as a potential solution to #22816

avatar luisorozoli
luisorozoli - comment - 16 Nov 2018

I have tested this item successfully on e775ecf


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22976.

avatar kukubayo
kukubayo - comment - 16 Nov 2018

I have tested this item successfully on e775ecf


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22976.

avatar luisorozoli luisorozoli - test_item - 16 Nov 2018 - Tested successfully
avatar kukubayo kukubayo - test_item - 16 Nov 2018 - Tested successfully
avatar Quy Quy - change - 16 Nov 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 16 Nov 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22976.

avatar mbabker mbabker - change - 17 Nov 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-11-17 17:29:49
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 17 Nov 2018
avatar mbabker mbabker - merge - 17 Nov 2018

Add a Comment

Login with GitHub to post a comment