2

I have a Symfony application that I develop on OS X and deploy to Debian Jessie, both running PHP 5.6.12. The Symfony (standard edition) version is the same on both systems: 2.7.3. The translator service is not enabled, the default_locale is set to de (German) on both systems, and there are no configuration differences in respect to I18n or locale handling.

In this application, there is a form that uses the “money” field type, with the currency set to EUR. On OS X, the field value is displayed with comma as decimal separator (as it is common in German) and with the “€” symbol after the field. On Debian Jessie, the decimal separator is a dot, and the “€” symbol is displayed left to the field. This behavior is the same for clients sending different “Accept-Language” request headers.

My questions are:

  • What can I do to make the Debian installation behave like the OS X installation, i.e. respect the de locale? Or asked differently: where might the difference in behavior come from?
  • The Sf2 documentation says “Depending on the currency - the currency symbol may be shown before or after the input text field.” On both systems, the currency is the same, but yet the behavior differs, so I guess the documentation is inaccurate. Or am I completely missing something?
BlueM
  • 3,658
  • 21
  • 34
  • Have you found the solution? I'm facing very same problem. – Dan Mironis Oct 14 '15 at 09:25
  • No, unfortunately not. Do you have exactly the same setup? – BlueM Oct 15 '15 at 17:24
  • No, I am developing on Windows and deploying on Ubuntu server. I didn't find global solution, tried setting locale globally and some other options - didn't help. So lastly I decided to use transformer + custom field type where I just replacing dot separator with comma. Not the best solution, but for now it works. – Dan Mironis Oct 15 '15 at 17:44

1 Answers1

2

You have to make sure that the php-intl extension is installed.

Because the Symfony Intl Component, which is a replacement layer for a missing php-intl extension only supports the locale: 'en', which you can see in their php files.

public function __construct($locale = 'en', $style = null, $pattern = null)
{
    if ('en' !== $locale && null !== $locale) {
        throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
    }
    ....
}

And also because an exception is thrown, if you try to call the following code.

\Locale::setDefault('de_DE');

The Symfony\Component\Intl\Locale\Locale::setDefault() is not implemented. Please install the "intl" extension for full localization capabilities.

500 Internal Server Error - MethodNotImplementedException

As the answer in the above linked Stackoverflow question states, you have to install php-intl. For me on Ubuntu somehow, that PHP-5 and PHP-7 is available was a problem. PHP5-intl was installed but not PHP7-intl. You should make sure by calling phpinfo(); that the extension is really loaded.

My answer assumes, that you have a locale configured in symfony, as I have done in the following lines:

framework:
    translator:      { fallbacks: ["%locale%", 'en'] }
    default_locale: de

The twig derivate in the symfony configuration also supports the following (for our issue unneccessary) entries:

date:
    format: d.m.Y, H:i:s
    interval_format: '%%d Tage'   
    timezone: Europe/Paris
number_format:
    decimals: 2
    decimal_point: ','
    thousands_separator: '.'
Community
  • 1
  • 1
Jakob Alexander Eichler
  • 2,988
  • 3
  • 33
  • 49
  • Thanks for the thorough explanation. Unfortunately, 10 days ago I relocated the project to a different server, so I cannot test if that was the real cause, but I verified that on the old server, the `intl` extension was missing, but on the new one (where the problem is not observable), `intl` is present, as it is on the OS X system. Therefore, it makes absolute sense to assume that this caused the issue. – BlueM Jul 26 '16 at 04:31