Skip to content
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

Negative prices missing minus #48

Open
jtojnar opened this issue Oct 2, 2021 · 5 comments
Open

Negative prices missing minus #48

jtojnar opened this issue Oct 2, 2021 · 5 comments
Labels

Comments

@jtojnar
Copy link
Owner

jtojnar commented Oct 2, 2021

On Wedos, the negative prices are listed as positive.

@jtojnar
Copy link
Owner Author

jtojnar commented Oct 2, 2021

Simple repro:

<?php
$formatter = new \NumberFormatter('en', \NumberFormatter::CURRENCY);
var_dump($formatter->format('-1'));

On Wedos (PHP 7.3), it returns string(8) "(¤1.00)", whereas locally, string(7) "-¤1.00", as expected (both PHP 8.0 and 7.3).

@jtojnar
Copy link
Owner Author

jtojnar commented Oct 2, 2021

Weirdly, for Czech, it shows the minus sign:

<?php
foreach (['cs', 'en'] as $lang) {
	foreach (['1', '-1'] as $val) {
		echo $lang . ' ' . $val . ' ';
		$formatter = new \NumberFormatter($lang, \NumberFormatter::CURRENCY);
		var_dump($formatter->format($val));
	}
}

Locally,

cs 1 string(9) "1,00 XXX"
cs -1 string(10) "-1,00 XXX"
en 1 string(6) "¤1.00"
en -1 string(7) "-¤1.00"

On Wedos:

cs 1 string(8) "1,00 ¤"
cs -1 string(9) "-1,00 ¤"
en 1 string(6) "¤1.00"
en -1 string(8) "(¤1.00)"

@jtojnar
Copy link
Owner Author

jtojnar commented Oct 2, 2021

The library actually uses formatCurrency internally so the symbol is already substituted.

<?php
foreach (['cs', 'en'] as $lang) {
	foreach (['1', '-1'] as $val) {
		echo $lang . ' ' . $val . ' ';
		$formatter = new \NumberFormatter($lang, \NumberFormatter::CURRENCY);
		var_dump($formatter->format($val));
	}
}

Locally,

cs 1 string(9) "1,00 Kč"
cs -1 string(10) "-1,00 Kč"
en 1 string(9) "CZK 1.00"
en -1 string(10) "-CZK 1.00"

On Wedos:

cs 1 string(9) "1,00 Kč"
cs -1 string(10) "-1,00 Kč"
en 1 string(7) "Kč1.00"
en -1 string(9) "(Kč1.00)"

@jtojnar
Copy link
Owner Author

jtojnar commented Oct 2, 2021

Likely, this is due to outdated ICU:

Locally:

Internationalization supportenabled
ICU version 64.2
ICU Data version 64.2
ICU Unicode version 12.1

Wedos:

Internationalization supportenabled
ICU version 4.2.1
ICU TZData version 2009j
ICU Unicode version 5.1

@jtojnar
Copy link
Owner Author

jtojnar commented Oct 2, 2021

I have asked Wedos to migrate the hosting to newer servers, which should support slightly less outdated services:

Internationalization supportenabled
ICU version 50.2
ICU Data version 50.2
ICU Unicode version 6.2

Let’s hope that fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant