-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
localize paginator counter output and CakeNumber::toPercentage #1431
Conversation
I wonder if it wouldn't be better to have l10n implement the required code to support LC_NUMERIC catalog files. Then each formatting class could use L10n/i18n as required. This would make numeric formatting similar to string and time formatting which also use LC_* catalog files. |
👍 to what mark said :) |
But doesnt that create more internal magic? Can't this have unforseen sideeffects in the code? A Configure value and controlled output via CakeNumber::format() does not seem to be that bad compared to that. Here is something I just stumbled upon: http://www.code-styling.de/english/php-function-setlocale-and-numbers-can-be-damaged. Easy to say if one doesn't need it.. Anyone who ever tried to work localized with LC_NUMERIC will discover that this is a nightmare. Especially the magic switching of separator/thousands. |
I'm suggesting we don't use setlocale(). I agree it has a number of a bad/unexpected side effects. Instead what I'm suggesting is extending the L10n/i18n classes to allow formatting of numbers in a region specific manner . One possible API example might be: // get a formatter
$formatter = L10n::numberFormatter('ja');
$formatted = $formatter->format($number); This would provide a similar system to $formatted = I18n::translate($value, null, null, LC_NUMERIC); This is a gross call signature, but could be wrapped with functions that provide a nicer API. |
And then let all other methods - including CakeNumber::format() internally use this formatter? |
Yes all the other methods including CakeNumber would delegate to l10n/i18n to do formatting. |
Currently L10n is still an issue throughout the core.
There are also different approachs.
One - using setlocale(LC_NUMERIC) I don't like as it creates even more issues and complicates things. Mainly because all the internal output is wrong then (it should stay in the normal numeric format). It also breaks lots of normal echo/output calls where there is also normal non-localized numbers expected.
As clean approach I recommend using two Configure values,
L10n.decimals
andL10n.thousands
.Those will mainly be used for any user output regarding localized numberic values then.
Resolves:
Long term I can see those values go into other places where localization should use those config values: