Passed
Push — master ( 108051...ff08b1 )
by Roeland
53:17 queued 23:58
created
lib/private/L10N/Factory.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	 * @return \OCP\IL10N
123 123
 	 */
124 124
 	public function get($app, $lang = null, $locale = null) {
125
-		return new LazyL10N(function () use ($app, $lang, $locale) {
125
+		return new LazyL10N(function() use ($app, $lang, $locale) {
126 126
 			$app = \OC_App::cleanAppId($app);
127 127
 			if ($lang !== null) {
128
-				$lang = str_replace(['\0', '/', '\\', '..'], '', (string)$lang);
128
+				$lang = str_replace(['\0', '/', '\\', '..'], '', (string) $lang);
129 129
 			}
130 130
 
131 131
 			$forceLang = $this->config->getSystemValue('force_language', false);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		 * @link https://github.com/owncloud/core/issues/21955
182 182
 		 */
183 183
 		if ($this->config->getSystemValue('installed', false)) {
184
-			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() :  null;
184
+			$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
185 185
 			if (!is_null($userId)) {
186 186
 				$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
187 187
 			} else {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		}
232 232
 
233 233
 		if ($this->config->getSystemValue('installed', false)) {
234
-			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() :  null;
234
+			$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null;
235 235
 			$userLocale = null;
236 236
 			if (null !== $userId) {
237 237
 				$userLocale = $this->config->getUserValue($userId, 'core', 'locale', null);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		// merge with translations from theme
313 313
 		$theme = $this->config->getSystemValue('theme');
314 314
 		if (!empty($theme)) {
315
-			$themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot));
315
+			$themeDir = $this->serverRoot.'/themes/'.$theme.substr($dir, strlen($this->serverRoot));
316 316
 
317 317
 			if (is_dir($themeDir)) {
318 318
 				$files = scandir($themeDir);
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			return $this->availableLocales;
339 339
 		}
340 340
 
341
-		$localeData = file_get_contents(\OC::$SERVERROOT . '/resources/locales.json');
341
+		$localeData = file_get_contents(\OC::$SERVERROOT.'/resources/locales.json');
342 342
 		$this->availableLocales = \json_decode($localeData, true);
343 343
 
344 344
 		return $this->availableLocales;
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 		$languageFiles = [];
504 504
 
505 505
 		$i18nDir = $this->findL10nDir($app);
506
-		$transFile = strip_tags($i18nDir) . strip_tags($lang) . '.json';
506
+		$transFile = strip_tags($i18nDir).strip_tags($lang).'.json';
507 507
 
508
-		if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/')
509
-				|| $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/')
510
-				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/')
508
+		if (($this->isSubDirectory($transFile, $this->serverRoot.'/core/l10n/')
509
+				|| $this->isSubDirectory($transFile, $this->serverRoot.'/lib/l10n/')
510
+				|| $this->isSubDirectory($transFile, \OC_App::getAppPath($app).'/l10n/')
511 511
 			)
512 512
 			&& file_exists($transFile)) {
513 513
 			// load the translations file
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		// merge with translations from theme
518 518
 		$theme = $this->config->getSystemValue('theme');
519 519
 		if (!empty($theme)) {
520
-			$transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot));
520
+			$transFile = $this->serverRoot.'/themes/'.$theme.substr($transFile, strlen($this->serverRoot));
521 521
 			if (file_exists($transFile)) {
522 522
 				$languageFiles[] = $transFile;
523 523
 			}
@@ -534,14 +534,14 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	protected function findL10nDir($app = null) {
536 536
 		if (in_array($app, ['core', 'lib'])) {
537
-			if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) {
538
-				return $this->serverRoot . '/' . $app . '/l10n/';
537
+			if (file_exists($this->serverRoot.'/'.$app.'/l10n/')) {
538
+				return $this->serverRoot.'/'.$app.'/l10n/';
539 539
 			}
540 540
 		} elseif ($app && \OC_App::getAppPath($app) !== false) {
541 541
 			// Check if the app is in the app folder
542
-			return \OC_App::getAppPath($app) . '/l10n/';
542
+			return \OC_App::getAppPath($app).'/l10n/';
543 543
 		}
544
-		return $this->serverRoot . '/core/l10n/';
544
+		return $this->serverRoot.'/core/l10n/';
545 545
 	}
546 546
 
547 547
 
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 			$plural = preg_replace('#[^n0-9:\(\)\?\|\&=!<>+*/\%-]#', '', $matches[2]);
565 565
 
566 566
 			$body = str_replace(
567
-				[ 'plural', 'n', '$n$plurals', ],
568
-				[ '$plural', '$n', '$nplurals', ],
569
-				'nplurals='. $nplurals . '; plural=' . $plural
567
+				['plural', 'n', '$n$plurals', ],
568
+				['$plural', '$n', '$nplurals', ],
569
+				'nplurals='.$nplurals.'; plural='.$plural
570 570
 			);
571 571
 
572 572
 			// add parents
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 						$res .= ') : (';
587 587
 						break;
588 588
 					case ';':
589
-						$res .= str_repeat(')', $p) . ';';
589
+						$res .= str_repeat(')', $p).';';
590 590
 						$p = 0;
591 591
 						break;
592 592
 					default:
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 				}
595 595
 			}
596 596
 
597
-			$body = $res . 'return ($plural>=$nplurals?$nplurals-1:$plural);';
597
+			$body = $res.'return ($plural>=$nplurals?$nplurals-1:$plural);';
598 598
 			$function = create_function('$n', $body);
599 599
 			$this->pluralFunctions[$string] = $function;
600 600
 			return $function;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		ksort($commonLanguages);
669 669
 
670 670
 		// sort now by displayed language not the iso-code
671
-		usort($languages, function ($a, $b) {
671
+		usort($languages, function($a, $b) {
672 672
 			if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
673 673
 				// If a doesn't have a name, but b does, list b before a
674 674
 				return 1;
Please login to merge, or discard this patch.