Display a notice if en-GB sys.ini file is missed

This commit is contained in:
Denis Ryabov 2023-09-21 16:43:08 +04:00
parent fe70110ce1
commit 7b45ccdb4f
2 changed files with 15 additions and 3 deletions

View File

@ -56,6 +56,7 @@ COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Domain names that use 'Joomla' or
COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG="Listing name ('%s') is too long, consider to shorten it"
COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'"
COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'"
COM_JEDCHECKER_INFO_XML_NO_LANGUAGE_FILE_FOUND="No '%1$s' language file was found for the '%2$s' language tag."
COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice"
COM_JEDCHECKER_RULE_PH1_DESC="A notice is required on each PHP file stating that the file is licensed GPL (or other compatible accepted license). For more information, please <a href='https://extensions.joomla.org/support/knowledgebase/submission-requirements/jed-entries-checklists/#licensechecklist' target='_blank'>click here</a>."
COM_JEDCHECKER_ERROR_GPL_NOT_FOUND="GPL or compatible license was not found"

View File

@ -150,7 +150,16 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
$type = (string) $xml['type'];
// Load the language of the extension (if any)
$this->loadExtensionLanguage($xml, dirname($file));
if (!$this->loadExtensionLanguage($xml, dirname($file))) {
$lang_file = JEDCheckerHelper::getElementName($xml) . '.sys.ini';
if ($type === 'plugin' && isset($xml['group']) && strpos($lang_file, 'plg_') !== 0)
{
$lang_file = 'plg_' . $xml['group'] . '_' . $lang_file;
}
$this->report->addNotice($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NO_LANGUAGE_FILE_FOUND', $lang_file, 'en-GB'));
}
// Get the real extension's name now that the language has been loaded
$lang = Factory::getLanguage();
@ -273,7 +282,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
* @param string $rootDir The basepath
* @param string $langTag The language to load
*
* @return void
* @return bool True if language file found, and false otherwise
*/
protected function loadExtensionLanguage($xml, $rootDir, $langTag = 'en-GB')
{
@ -353,10 +362,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
$loadLanguage = new ReflectionMethod($lang, 'loadLanguage');
$loadLanguage->setAccessible(true);
$loadLanguage->invoke($lang, $langSysFile, $extension);
return;
return true;
}
}
}
return false;
}
/**