forked from hql287/Manta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DarkSmile92
committed
Jan 23, 2018
1 parent
a608f67
commit 4ef3284
Showing
1 changed file
with
10 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
const appConfig = require('electron').remote.require('electron-settings'); | ||
|
||
function roundValue(value) { | ||
// This variable my get value from setting in future version | ||
const decimals = 2; | ||
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals); | ||
} | ||
|
||
function formatNumber(number) { | ||
return roundValue(number).toLocaleString(); | ||
function formatNumber(number, locale) { | ||
if (!locale) { | ||
locale = appConfig.get('general.language') || 'en'; | ||
} | ||
return roundValue(number).toLocaleString(locale, { | ||
minimumFractionDigits: 2, | ||
maximumFractionDigits: 2 | ||
}); | ||
} | ||
|
||
export { formatNumber }; |