Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTM] Improve the locale handling #1064

Closed
wants to merge 8 commits into from

Conversation

leofeyer
Copy link
Member

This PR caches the installed languages in the DI container, so we do not need to iterate over the file system upon every request. Also, it no longer stores the locale in the session by default, which is now done in the setUserFromDb() method.

@leofeyer leofeyer added this to the 4.5.0 milestone Sep 11, 2017
@leofeyer leofeyer self-assigned this Sep 11, 2017
@leofeyer leofeyer requested a review from ausi September 11, 2017 14:40

$finder = Finder::create()->directories()->depth(0)->in($dirs);

$languages = array_values(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$languages = [$this->defaultLocale];

foreach ($finder as $file) {
    if (preg_match('/^[a-z]{2}(_[A-Z]{2})?$/', $file->getFilename())) {
        $languages[] = $file->getFilename();
    }
}

return array_values(array_unique($languages));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 6bcce67.

@contao contao deleted a comment from aschempp Sep 12, 2017
$finder = Finder::create()->directories()->depth(0)->in($dirs);

foreach ($finder as $file) {
if (preg_match('/^[a-z]{2}(_[A-Z]{2})?$/', $file->getFilename())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the $finder do that already? Like so:

$finder = Finder::create()->directories()->depth(0)->in($dirs)->name('/^[a-z]{2}(_[A-Z]{2})?$/');

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 4f35589.

@@ -51,7 +51,8 @@ public function getConfiguration(array $config, ContainerBuilder $container)

return new Configuration(
$container->getParameter('kernel.debug'),
$container->getParameter('kernel.project_dir')
$container->getParameter('kernel.project_dir'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be kernel.root_dir

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in be52c2c.

@contao contao deleted a comment from aschempp Sep 12, 2017
@leofeyer leofeyer changed the title Improve the locale handling [RTM] Improve the locale handling Sep 12, 2017
leofeyer added a commit that referenced this pull request Sep 18, 2017
@leofeyer
Copy link
Member Author

Merged in b40a935.

@leofeyer leofeyer closed this Sep 18, 2017
@leofeyer leofeyer deleted the feature/improve-locale-handling branch September 18, 2017 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants