-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This improves how talks in the other language are displayed. Up until now, you could have a talk in English on a `.cz` site and vice versa which I think caused some troubles for search engines and people alike. So now when the talk is in English, you'll have a `.com` link in the list of talks together with a flag icon and a language name. Also, HTTP redirects will take you where you're supposed to be, English talks on `.com` site etc., when you're not. Also, if there's an other locale talk, and it's correctly paired with the original locale talk using `key_translation_group`, you'll have a link in the header directly to the talk in the other locale. Follow-up to #194 #192
- Loading branch information
Showing
27 changed files
with
335 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Application; | ||
|
||
class LocaleLink | ||
{ | ||
|
||
public function __construct( | ||
private readonly string $locale, | ||
private readonly string $languageCode, | ||
private readonly string $languageName, | ||
private readonly string $url, | ||
) { | ||
} | ||
|
||
|
||
public function getLocale(): string | ||
{ | ||
return $this->locale; | ||
} | ||
|
||
|
||
public function getLanguageCode(): string | ||
{ | ||
return $this->languageCode; | ||
} | ||
|
||
|
||
public function getLanguageName(): string | ||
{ | ||
return $this->languageName; | ||
} | ||
|
||
|
||
public function getUrl(): string | ||
{ | ||
return $this->url; | ||
} | ||
|
||
|
||
public function withUrl(string $url): self | ||
{ | ||
return new self( | ||
$this->getLocale(), | ||
$this->getLanguageCode(), | ||
$this->getLanguageName(), | ||
$url, | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace MichalSpacekCz\Talks; | ||
|
||
use Nette\Database\Explorer; | ||
|
||
class TalkLocaleUrls | ||
{ | ||
|
||
public function __construct( | ||
private readonly Explorer $database, | ||
) { | ||
} | ||
|
||
|
||
/** | ||
* @return array<string, string> locale => action | ||
*/ | ||
public function get(Talk $talk): array | ||
{ | ||
if (!$talk->getTranslationGroupId()) { | ||
return []; | ||
} | ||
return $this->database->fetchPairs( | ||
'SELECT l.locale, t.action FROM talks t JOIN locales l ON t.key_locale = l.id_locale WHERE t.key_translation_group = ?', | ||
$talk->getTranslationGroupId(), | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.