8000 Loading translation resources performances · Issue #13556 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Loading translation resources performances #13556

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

Closed
umpirsky opened this issue Jan 30, 2015 · 3 comments
Closed

Loading translation resources performances #13556

umpirsky opened this issue Jan 30, 2015 · 3 comments

Comments

@umpirsky
Copy link
Contributor

I was profiling Sylius recently, and noticed that there is some time wasted on each request on adding resources to translator service.

We have a lots of resources in Sylius (around 2000), but also don't see the reason to add each of them in production mode like this:

// app/cache/prod/appProdProjectContainer.php

protected function getTranslator_DefaultService()
{
    $this->services['translator.default'] = $instance = new \Symfony\Bundle\FrameworkBundle\Translation\Translator($this, new \Symfony\Component\Translation\MessageSelector(), array('translation.loader.php' => array(0 => 'php'), 'translation.loader.yml' => array(0 => 'yml'), 'translation.loader.xliff' => array(0 => 'xlf', 1 => 'xliff'), 'translation.loader.po' => array(0 => 'po'), 'translation.loader.mo' => array(0 => 'mo'), 'translation.loader.qt' => array(0 => 'ts'), 'translation.loader.csv' => array(0 => 'csv'), 'translation.loader.res' => array(0 => 'res'), 'translation.loader.dat' => array(0 => 'dat'), 'translation.loader.ini' => array(0 => 'ini')), array('cache_dir' => (__DIR__.'/translations'), 'debug' => false));
    $instance->setFallbackLocales(array(0 => 'en'));

    $instance->addResource('xlf', (dirname(dirname(dirname(__DIR__))).'/vendor/symfony/symfony/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf'), 'sv', 'validators');

    // ...

    $instance->addResource('yml', (dirname(dirname(__DIR__)).'/Resources/translations/FOSUserBundle.en.yml'), 'en', 'FOSUserBundle');

    return $instance;
}

It brings something like ~60 ms delay for each page load, and I don't think it is necessary since translations are read from app/cache/prod/translations/catalogue.en.php in production environment.

@cystbear
Copy link
Contributor

👍

@aitboudad
Copy link
Contributor

Fixed by #13897 @umpirsky could you please, check it?

@umpirsky
Copy link
Contributor Author

@aitboudad Great idea, thanks for looking into this!

fabpot added a commit that referenced this issue Mar 13, 2015
…o Translator initialize. (aitboudad)

This PR was squashed before being merged into the 2.7 branch (closes #13897).

Discussion
----------

[translation][performances] move loading resources into Translator initialize.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets  | #13556
| Tests pass?   | yes
| License       | MIT

Commits
-------

bf5c583 [translation][performances] move loading resources into Translator initialize.
@fabpot fabpot closed this as completed Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0