Skip to content

Commit

Permalink
FIX decimal separator should be used from Locale (trustwallet#927)
Browse files Browse the repository at this point in the history
* FIX decimal separator should be used from Locale

* Update EtherNumberFormatter.swift
  • Loading branch information
manhlx3006 authored and vikmeup committed Nov 16, 2018
1 parent 6a911e7 commit 262b8a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Trust/Foundation/EtherNumberFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ final class EtherNumberFormatter {

/// Thousands separator.
var groupingSeparator = ","

let locale: Locale

/// Initializes a `EtherNumberFormatter` with a `Locale`.
init(locale: Locale = .current) {
self.locale = locale
decimalSeparator = locale.decimalSeparator ?? "."
groupingSeparator = locale.groupingSeparator ?? ","
}
Expand Down Expand Up @@ -103,7 +106,7 @@ final class EtherNumberFormatter {
if fractionalString.isEmpty {
return integerString
}
return "\(integerString).\(fractionalString)"
return "\(integerString)\(self.decimalSeparator)\(fractionalString)"
}
/// Formats a `BigInt` to a Decimal.
///
Expand All @@ -121,7 +124,7 @@ final class EtherNumberFormatter {
if fractionalString.isEmpty {
return Decimal(string: integerString)
}
return Decimal(string: "\(integerString).\(fractionalString)")
return Decimal(string: "\(integerString)\(self.decimalSeparator)\(fractionalString)", locale: locale)
}
private func integerString(from: BigInt) -> String {
var string = from.description
Expand Down

0 comments on commit 262b8a1

Please sign in to comment.