Leaseweb / LswGettextTranslationBundle

Symfony2 bundle that adds native (faster) gettext translation support and is easy to use.
MIT License
24 stars 8 forks source link

Config option to disable Gettext listener #6

Open althaus opened 10 years ago

althaus commented 10 years ago

Hey,

we just added your nifty bundle to a project, but we already have some custom gettext handler/listener. It'd be great if there'd be a config option to en/disable the bundle's services. For now I've just overriden yours with an empty dummy listener.

http://symfony.com/doc/current/cookbook/bundles/configuration.html

Cheers Matthias

mevdschee commented 10 years ago

Hi Matthias, thank you for your comment. Can you be a little more specific in how you want this to work? What would be the name of the configuration parameter and what would it exactly do? Also, if you are willing to do a PR, then I am willing to merge that. As long as it enables the listener by default and does not break backwards compatibility. Kind regards, Maurits

althaus commented 10 years ago

Hey,

my issue is that the GettextLocaleListener is always executing setupGetText()

private function setupGetText()
{
    $versionFile = $this->rootDir.'/Resources/gettext/version';
    $version = file_exists($versionFile) ? file_get_contents($versionFile) : '';
    $domain = 'messages' . $version;
    bindtextdomain($domain, $this->rootDir . '/Resources/gettext/combined/');
    textdomain($domain);
    bind_textdomain_codeset($domain, 'UTF-8');
}

and that's breaking our custom Gettext setup. In addition we have our own listener setting the request locale. Therefore I'd be great if the config would include options to disable those listeners:

# app/config/config.yml
lsw_gettext:
    locale_listener: false

I'll check this out to see if I can to a PR. :)

Cheers

mevdschee commented 10 years ago

That would be great! If I find some time I can also try to make this.. should not be too hard. :-)