diff --git a/src/cutecoin/core/money/quant_zerosum.py b/src/cutecoin/core/money/quant_zerosum.py index 340c350a35fceb8ea52f5586a10a298b423db8b8..17a8dbc36027cd0686613100159ee6fcda7ccaf8 100644 --- a/src/cutecoin/core/money/quant_zerosum.py +++ b/src/cutecoin/core/money/quant_zerosum.py @@ -42,16 +42,20 @@ class QuantitativeZSum: def differential(self): return Quantitative(self.amount, self.community, self.app).compute() - def localized(self, pretty_print=False): + def localized(self, units=False, international_system=False): value = self.value() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', 0) + localized_value = QLocale().toString(float(value), 'f', 0) + + if units: return QCoreApplication.translate("QuantitativeZSum", QuantitativeZSum._REF_STR_) \ - .format(strvalue, - self.community.short_currency) + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value - def diff_localized(self, pretty_print=False): - return Quantitative(self.amount, self.community, self.app).localized(pretty_print) \ No newline at end of file + def diff_localized(self, units=False, international_system=False): + return Quantitative(self.amount, self.community, self.app).localized(units, international_system) \ No newline at end of file diff --git a/src/cutecoin/core/money/quantitative.py b/src/cutecoin/core/money/quantitative.py index aae9074975bc8bdfb3eaca9ccb0ed897abd2e563..03bc237a97a16c5011109149f07d87f2ed2366c8 100644 --- a/src/cutecoin/core/money/quantitative.py +++ b/src/cutecoin/core/money/quantitative.py @@ -36,24 +36,32 @@ class Quantitative(): def differential(self): return self.value() - def localized(self, pretty_print=False): + def localized(self, units=False, international_system=False): value = self.value() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', 0) + localized_value = QLocale().toString(float(value), 'f', 0) + + if units: return QCoreApplication.translate("Quantitative", Quantitative._REF_STR_) \ - .format(strvalue, - self.community.short_currency) + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value - def diff_localized(self, pretty_print=False): + def diff_localized(self, units=False, international_system=False): value = self.differential() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', 0) + localized_value = QLocale().toString(float(value), 'f', 0) + + if units: return QCoreApplication.translate("Quantitative", Quantitative._REF_STR_) \ - .format(strvalue, - self.community.short_currency) + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value diff --git a/src/cutecoin/core/money/relative.py b/src/cutecoin/core/money/relative.py index bcc29ffe8b84d306f20a3bdca6fc75a4b63aa97e..fa780d65d28fd5c4a8a8bdd803280e6951417266 100644 --- a/src/cutecoin/core/money/relative.py +++ b/src/cutecoin/core/money/relative.py @@ -39,20 +39,30 @@ class Relative(): def differential(self): return self.value() - def localized(self, pretty_print=False): + def localized(self, units=False, international_system=False): value = self.value() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue, - self.community.short_currency) + localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - def diff_localized(self, pretty_print=False): + if units: + return QCoreApplication.translate("Relative", Relative._REF_STR_) \ + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value + + def diff_localized(self, units=False, international_system=False): value = self.differential() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue, - self.community.short_currency) + localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) + + if units: + return QCoreApplication.translate("Relative", Relative._REF_STR_)\ + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value diff --git a/src/cutecoin/core/money/relative_zerosum.py b/src/cutecoin/core/money/relative_zerosum.py index b414830430c531f612ba4db2bb33060ef07c7683..788772acb957cca3d07a6db339add134a295520b 100644 --- a/src/cutecoin/core/money/relative_zerosum.py +++ b/src/cutecoin/core/money/relative_zerosum.py @@ -44,20 +44,30 @@ class RelativeZSum: def differential(self): return Relative(self.amount, self.community, self.app).value() - def localized(self, pretty_print=False): + def localized(self, units=False, international_system=False): value = self.value() - if pretty_print: + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(strvalue, - self.community.short_currency) + localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - def diff_localized(self, pretty_print=False): + if units: + return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_)\ + .format(localized_value, + self.community.short_currency if units else "") + else: + return localized_value + + def diff_localized(self, units=False, international_system=False): value = self.differential() - if pretty_print: + + if international_system: pass else: - strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) - return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(strvalue, - self.community.short_currency) + localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) + + if units: + return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_)\ + .format(localized_value, self.community.short_currency if units else "") + else: + return localized_value diff --git a/src/cutecoin/gui/wallets_tab.py b/src/cutecoin/gui/wallets_tab.py index 06fae7b645d43f4b4cfa7349e9bda5618ab862e8..32e601f33e3359a3655f1319e8bf8cc8caedc71e 100644 --- a/src/cutecoin/gui/wallets_tab.py +++ b/src/cutecoin/gui/wallets_tab.py @@ -141,9 +141,9 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab): maximum = self.community.monetary_mass # if referential type is quantitative... # display int values - localized_amount = self.account.current_ref(amount, self.community, self.app).localized() - localized_minimum = self.account.current_ref(maximum, self.community, self.app).localized() - localized_maximum = self.account.current_ref(0, self.community, self.app).localized() + localized_amount = self.account.current_ref(amount, self.community, self.app).localized(units=True) + localized_minimum = self.account.current_ref(0, self.community, self.app).localized(units=True) + localized_maximum = self.account.current_ref(maximum, self.community, self.app).localized(units=True) # set infos in label self.label_balance.setText(