Review main Abandoned

47158[FEATURE] Set the locale based on language in user settings

Michiel Roos CR 0 V 0 Normal +87 −1 updated 04/21/17, 13:46

Commit message

During bootstrap, the language code will be looked up in the language
code array in \TYPO3\CMS\Core\Localization\Locales.

PHP setlocale() will be called with a list of locale codes preferring
a UTF-8 version of the locale.

If no locale is found, the original locale is restored.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 10

  1. Michiel Roos uploaded patch set 1 03/08/16, 22:15

  2. Xavier Perseguers commented on patch set 1 03/09/16, 07:33

    Locales.php:114

    In Switzerland we use "fr_CH" and abbreviated week days and short dates are not the same as fr_FR
  3. Michiel Roos uploaded patch set 2 03/09/16, 08:11

  4. Oliver Klee commented on patch set 2 CR -1 03/09/16, 10:03

    LanguageService.php:154

    Please don't change LC_ALL. Changing the locale will change the way floats will be rendered, e.g. "3.14159" might be rendered as "3,14159". So at least LC_NUMERIC must not be changed.
  5. Michiel Roos commented on patch set 2 03/09/16, 13:51

    Locales.php:114 Reply

    Yep, same goes for en / default. That can be either en_US or en_GB. A solution would be to 'extend' the list of languages. This is currently already done for chinese Traditional (zh) and simplified (ch). But I think the best solution here then would be to use the ISO codes as the keys in $this->languages. That will ease the setting of the locale. A mapping will need to be added to map those keys to available TYPO3 translations. So that both fr_CH and fr_FR map tho the 'french' translation of TYPO3. Maybe we can get away with snipping off the "_XX" part.

    LanguageService.php:154 Reply

    Ehm, This is exactly the point of the patch. Backend users should be able to display the information in the backend formatted according to their chosen locale. When they choose a different language in user settings the rendering of numbers should reflect that choice too.
  6. Oliver Klee commented on patch set 2 03/09/16, 13:57

    LanguageService.php:154 Reply

    This will also affect places where we e.g. write floats from PHP to JavaScript, leading to invalid JavaScript. We must not do this (I've been bitten by this), but use number_format instead for numbers.
  7. Michiel Roos commented on patch set 2 03/09/16, 14:24

    LanguageService.php:154 Reply

    Can we not find those places and to something like: https://github.com/symfony/yaml/blob/master/Inline.php#L182 ?
  8. Oliver Klee commented on patch set 2 03/09/16, 15:31

    "Those places" is everywhere a float is used within a string or as part of some output. And I would not count on every future developer to remember that they must not simply use floats in these contexts.
  9. Benni Mack commented on patch set 2 CR -1 04/21/17, 13:35

    LanguageService.php:154 Reply

    Also, initializing this in here breaks Frontend: TSFE sets setlocale() as well, and $LANG is also initialized. What should be the expected behaviour then? Also, see the changes around that area in TSFE because we had some regressions already because of setting LC_ALL (we do set a list of other LC_* values instead).
  10. Michiel Roos abandoned the change 04/21/17, 13:46