diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 5780104..fdd5407 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -87,6 +87,7 @@ COM_JEDCHECKER_LANG_KEY_EMPTY="Empty key name" COM_JEDCHECKER_LANG_KEY_WHITESPACE="Whitespace in the key is not allowed" COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER="Incorrect character in the key name" COM_JEDCHECKER_LANG_KEY_RESERVED="Reserved keyword in the key name" +COM_JEDCHECKER_LANG_TRANSLATION_ERROR="Incorrect translation string" COM_JEDCHECKER_LANG_TRANSLATION_QUOTES="All translation strings should be in double quotation marks" COM_JEDCHECKER_LANG_TRANSLATION_EMPTY="Empty translation string" COM_JEDCHECKER_LANG_QQ_DEPRECATED="Usage of \"_QQ_\" is deprecated since Joomla! 3.9. Use escaped double quotes (\\\") instead" diff --git a/administrator/components/com_jedchecker/libraries/rules/language.php b/administrator/components/com_jedchecker/libraries/rules/language.php index 54fff9c..e2cb45f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/language.php +++ b/administrator/components/com_jedchecker/libraries/rules/language.php @@ -145,6 +145,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule continue; } + $value = trim($matches[1]); // Check for empty value if ($value === '""') { @@ -152,6 +153,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule continue; } + if (strlen($value) < 2 || $value[0] !== '"' || substr($value, -1) !== '"') // Remove quotes around $value = substr($value, 1, -1); @@ -160,6 +162,17 @@ class JedcheckerRulesLanguage extends JEDcheckerRule { $this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_QQ_DEPRECATED'), $lineno, $line); } + + // Count %... formats in the string + $count1 = preg_match_all('/(?<=^|[^%])%(?=[-+0 ]?\w)/', $value); + + // Count %n$... (argnum) formats in the string + $count2 = preg_match_all('/(?<=^|[^%])%\d+\$/', $value); + + if ($count1 > 1 && $count2 < $count1) { + // @todo It's not mentioned in docs + $this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_RECOMMEND_ARGNUM'), $startLineno, $line); + } } // All checks passed. Return true