33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-28 07:46:34 +00:00

check for duplicated translation keys

This commit is contained in:
Denis Ryabov 2021-02-23 23:44:53 +03:00
parent 134e4c0588
commit a7aa53ac31
2 changed files with 11 additions and 0 deletions

View File

@ -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_KEY_DUPLICATED="The key name was declared previously on line %d"
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"

View File

@ -73,6 +73,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
{
$lines = file($file);
$nLines = count($lines);
$keys = array();
for ($lineno = 0; $lineno < $nLines; $lineno++)
{
@ -142,6 +143,15 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
continue;
}
if (isset($keys[$key]))
{
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_LANG_KEY_DUPLICATED', $keys[$key]), $startLineno, $line);
}
else
{
$keys[$key] = $startLineno;
}
// Validate value
$value = ltrim($value);