1414
1515class FileValidator
1616{
17+ /** @var string */
18+ protected $ direction ;
1719 /** @var string */
1820 protected $ originIso ;
1921 /** @var string */
@@ -39,6 +41,9 @@ class FileValidator
3941 /** @var \Phpbb\TranslationValidator\Output\OutputInterface */
4042 protected $ output ;
4143
44+ /** @var LangKeyValidator */
45+ protected $ langKeyValidator ;
46+
4247 /** @var array List from https://developers.google.com/recaptcha/docs/language */
4348 private $ reCaptchaLanguages = [
4449 'ar ' ,
@@ -122,7 +127,19 @@ public function __construct(InputInterface $input, OutputInterface $output)
122127 {
123128 $ this ->input = $ input ;
124129 $ this ->output = $ output ;
125- $ this ->langkeyValidator = new LangKeyValidator ($ input , $ output );
130+ $ this ->langKeyValidator = new LangKeyValidator ($ input , $ output );
131+ }
132+
133+ /**
134+ * Set the language direction
135+ * @param $direction
136+ * @return $this
137+ */
138+ public function setDirection ($ direction )
139+ {
140+ $ this ->direction = $ direction ;
141+ $ this ->langKeyValidator ->setDirection ($ direction );
142+ return $ this ;
126143 }
127144
128145 /**
@@ -138,7 +155,7 @@ public function setOrigin($originIso, $originPath, $originLanguagePath)
138155 $ this ->originIso = $ originIso ;
139156 $ this ->originPath = $ originPath ;
140157 $ this ->originLanguagePath = $ originLanguagePath ;
141- $ this ->langkeyValidator ->setOrigin ($ originIso , $ originPath , $ originLanguagePath );
158+ $ this ->langKeyValidator ->setOrigin ($ originIso , $ originPath , $ originLanguagePath );
142159 return $ this ;
143160 }
144161
@@ -155,7 +172,7 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath)
155172 $ this ->sourceIso = $ sourceIso ;
156173 $ this ->sourcePath = $ sourcePath ;
157174 $ this ->sourceLanguagePath = $ sourceLanguagePath ;
158- $ this ->langkeyValidator ->setSource ($ sourceIso , $ sourcePath , $ sourceLanguagePath );
175+ $ this ->langKeyValidator ->setSource ($ sourceIso , $ sourcePath , $ sourceLanguagePath );
159176 return $ this ;
160177 }
161178
@@ -168,7 +185,7 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath)
168185 public function setPhpbbVersion ($ phpbbVersion )
169186 {
170187 $ this ->phpbbVersion = $ phpbbVersion ;
171- $ this ->langkeyValidator ->setPhpbbVersion ($ phpbbVersion );
188+ $ this ->langKeyValidator ->setPhpbbVersion ($ phpbbVersion );
172189 return $ this ;
173190 }
174191
@@ -181,7 +198,7 @@ public function setPhpbbVersion($phpbbVersion)
181198 public function setPluralRule ($ pluralRule )
182199 {
183200 $ this ->pluralRule = $ pluralRule ;
184- $ this ->langkeyValidator ->setPluralRule ($ pluralRule );
201+ $ this ->langKeyValidator ->setPluralRule ($ pluralRule );
185202 return $ this ;
186203 }
187204
@@ -194,7 +211,7 @@ public function setPluralRule($pluralRule)
194211 public function setDebug ($ debug )
195212 {
196213 $ this ->debug = $ debug ;
197- $ this ->langkeyValidator ->setDebug ($ debug );
214+ $ this ->langKeyValidator ->setDebug ($ debug );
198215 return $ this ;
199216 }
200217
@@ -346,7 +363,7 @@ public function validateLangFile($sourceFile, $originFile)
346363 continue ;
347364 }
348365
349- $ this ->langkeyValidator ->validate ($ originFile , $ againstLangKey , $ againstLanguage , $ validate [$ againstLangKey ]);
366+ $ this ->langKeyValidator ->validate ($ originFile , $ againstLangKey , $ againstLanguage , $ validate [$ againstLangKey ]);
350367 }
351368
352369 foreach ($ validate as $ validateLangKey => $ validateLanguage )
@@ -555,13 +572,13 @@ public function validateHelpFile($sourceFile, $originFile)
555572 if (isset ($ help [0 ]))
556573 {
557574 $ compare = isset ($ against [$ entry ][0 ]) ? $ against [$ entry ][0 ] : '' ;
558- $ this ->langkeyValidator ->validate ($ originFile , $ entry . '.0 ' , $ compare , $ help [0 ]);
575+ $ this ->langKeyValidator ->validate ($ originFile , $ entry . '.0 ' , $ compare , $ help [0 ]);
559576 }
560577
561578 if (isset ($ help [1 ]))
562579 {
563580 $ compare = isset ($ against [$ entry ][1 ]) ? $ against [$ entry ][1 ] : '' ;
564- $ this ->langkeyValidator ->validate ($ originFile , $ entry . '.1 ' , $ compare , $ help [1 ]);
581+ $ this ->langKeyValidator ->validate ($ originFile , $ entry . '.1 ' , $ compare , $ help [1 ]);
565582 }
566583 $ entry ++;
567584 }
@@ -817,7 +834,8 @@ public function validateCSSFile($sourceFile, $originFile)
817834 }
818835 if (!empty ($ additionalRules ))
819836 {
820- $ this ->output ->addMessage (Output::FATAL , 'Stylesheet file has additional CSS rules: ' . implode (', ' , $ additionalRules ), $ originFile );
837+ $ additionalRulesLevel = ($ this ->direction == 'rtl ' ) ? Output::WARNING : Output::FATAL ; // be more lenient for RTL
838+ $ this ->output ->addMessage ($ additionalRulesLevel , 'Stylesheet file has additional CSS rules: ' . implode (', ' , $ additionalRules ), $ originFile );
821839 }
822840 }
823841
0 commit comments