namespace OC\L10N;
+use Ds\Set;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
*/
protected $availableLanguages = [];
+ /**
+ * @var Set
+ */
+ protected $localeCache;
+
/**
* @var array
*/
$this->request = $request;
$this->userSession = $userSession;
$this->serverRoot = $serverRoot;
+ $this->localeCache = new Set();
}
/**
return true;
}
- $locales = $this->findAvailableLocales();
- $userLocale = array_filter($locales, function ($value) use ($locale) {
- return $locale === $value['code'];
- });
+ if ($this->localeCache->isEmpty()) {
+ $locales = $this->findAvailableLocales();
+ foreach ($locales as $l) {
+ $this->localeCache->add($l['code']);
+ }
+ }
- return !empty($userLocale);
+ return $this->localeCache->contains($locale);
}
/**