Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Locale IDs for tl_page.language (see #2305)
Description ----------- | Q | A | -----------------| --- | Fixed issues | Fixes contao/contao#1957 Since Contao 4.10, the URL prefix is no longer tied to the page language. With this PR, the page language can be any valid Locale ID. A Locale ID can include language, script, country and additional information (e.g. `de_Latn_CH@currency=EUR`), see https://github.com/contao/core-bundle/issues/233. Locale ID and ICU information can later be used a lot more things like rewriting the number formatting to use the ICU information (decimal point according to language & country). Commits ------- c45065b5 Use Locale ID for tl_page.language 832f980f Migrate the existing page languages 4372b7e3 Format locale instead of string replace 7fa7cf79 Support old locale style in legacy routing f5b0c0c5 Added support for full locale routing af357553 Do not migrate the page language 4b5c98a0 Updated hint for page language field 6d303ea6 Use a listener for the page language callback 40bfc173 Use method to calculate locale priority 0c22b1bb CS bc4abe59 Fixed tests 95293af0 Feedback adjustments 3a853b8f Migrate the page languages de7b8d7c Always convert page language and make sure it starts with two letters c2ca955d Only support correctly formatted language folders e149b37a Fix user and member language fields 300d40f2 Fixed rebase issues edfff9ad CS bfb0cf68 Merge branch '4.x' into feature/locale 3ad4a000 CS
- Loading branch information
Showing
44 changed files
with
451 additions
and
135 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
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,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Contao. | ||
* | ||
* (c) Leo Feyer | ||
* | ||
* @license LGPL-3.0-or-later | ||
*/ | ||
|
||
namespace Contao\CoreBundle\Migration\Version412; | ||
|
||
use Contao\CoreBundle\Migration\AbstractMigration; | ||
use Contao\CoreBundle\Migration\MigrationResult; | ||
use Contao\CoreBundle\Util\LocaleUtil; | ||
use Doctrine\DBAL\Connection; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class PageLanguageMigration extends AbstractMigration | ||
{ | ||
/** | ||
* @var Connection | ||
*/ | ||
private $connection; | ||
|
||
public function __construct(Connection $connection) | ||
{ | ||
$this->connection = $connection; | ||
} | ||
|
||
public function shouldRun(): bool | ||
{ | ||
$schemaManager = $this->connection->getSchemaManager(); | ||
|
||
if (!$schemaManager->tablesExist(['tl_page'])) { | ||
return false; | ||
} | ||
|
||
$pageColumns = $schemaManager->listTableColumns('tl_page'); | ||
|
||
if (!isset($pageColumns['language'])) { | ||
return false; | ||
} | ||
|
||
$count = $this->connection->fetchOne(" | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
tl_page | ||
WHERE | ||
type='root' AND SUBSTRING(language, 3, 1) = '-' | ||
"); | ||
|
||
return $count > 0; | ||
} | ||
|
||
public function run(): MigrationResult | ||
{ | ||
$pages = $this->connection->fetchAllAssociative(" | ||
SELECT | ||
id, language | ||
FROM | ||
tl_page | ||
WHERE | ||
type='root' AND SUBSTRING(language, 3, 1) = '-' | ||
"); | ||
|
||
foreach ($pages as $page) { | ||
$this->connection->update( | ||
'tl_page', | ||
['language' => LocaleUtil::canonicalize($page['language'])], | ||
['id' => $page['id']] | ||
); | ||
} | ||
|
||
return $this->createResult(true); | ||
} | ||
} |
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
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
Oops, something went wrong.