Check for same language

This commit is contained in:
Philipp Holzer 2019-12-29 16:39:25 +01:00
parent 7a2f4dc54e
commit 71a38180e9
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90

View file

@ -413,6 +413,11 @@ class L10n
*/ */
public function withLang(string $lang) public function withLang(string $lang)
{ {
// Don't create a new instance for same language
if ($lang === $this->lang) {
return $this;
}
$newL10n = clone $this; $newL10n = clone $this;
$newL10n->loadTranslationTable($lang); $newL10n->loadTranslationTable($lang);
return $newL10n; return $newL10n;