-
Notifications
You must be signed in to change notification settings - Fork 234
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
Use Normal Negative Currency #1300
Comments
It seems to be a small step to make that happen. You can reformat, but the manually set pre- and suffixes are not exclusively assigned. First things first: Locale.define('en-US', 'Number', {
currency: {
prefix: '$ ',
negative: {
prefix: '(',
suffix: ')'
}
}
}); But it will get harder if Locale.define('te-st').inherit('EU', 'Number');
Locale.define('te-st', 'Number', {
currency: {
prefix: '€ ',
suffix: '+',
negative: {
exclusive: true, // to be implemented ;)
prefix: '-Eur ',
suffix: '-'
}
}
});
Locale.use('te-st');
(-1337.42).formatCurrency();
// will output:
// € -Eur 1.337,42+- So just change https://github.com/mootools/mootools-more/blob/master/Source/Types/Number.Format.js#L35 to: if (negativeLocale[key] != null) options[key] = (negativeLocale.exclusive ? '' : getOption(key)) + negativeLocale[key]; The With this fix, it will output See: https://jsfiddle.net/nc7fu62j/2/ Review at https://github.com/boppy/mootools-more/tree/fix-currency-bug-1300 |
The MooTools formatCurrency uses a non-standard negative/prefix combination.
In MooTools the currency prefix is in front of the negative prefix. So currency is formatted like
$ -2,000.00
and$ (2,000.00)
The standard seems to be
-$2,000.00
and($2,000.00)
Swapping the prefix ordering means it probably would break everything else... so more custom logic just for Currency? Seems like overkill.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9195794-use-normal-negative-currency?utm_campaign=plugin&utm_content=tracker%2F22069&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22069&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: