Skip to content

Commit 97402d5

Browse files
BogdanUngureanudevnexen
authored andcommitted
ext/intl: Add DECIMAL_COMPACT_SHORT and DECIMAL_COMPACT_LONG for NumberFormatter class
close GH-17975
1 parent af704ae commit 97402d5

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

ext/intl/formatter/formatter.stub.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class NumberFormatter
1111
public const int PATTERN_DECIMAL = UNKNOWN;
1212
/** @cvalue UNUM_DECIMAL */
1313
public const int DECIMAL = UNKNOWN;
14+
/** @cvalue UNUM_DECIMAL_COMPACT_SHORT */
15+
public const int DECIMAL_COMPACT_SHORT = UNKNOWN;
16+
/** @cvalue UNUM_DECIMAL_COMPACT_LONG */
17+
public const int DECIMAL_COMPACT_LONG = UNKNOWN;
1418
/** @cvalue UNUM_CURRENCY */
1519
public const int CURRENCY = UNKNOWN;
1620
/** @cvalue UNUM_PERCENT */

ext/intl/formatter/formatter_arginfo.h

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
numfmt_format_currency() icu >= 4.8
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
function ut_main()
9+
{
10+
$locales = array(
11+
'en_UK',
12+
'en_US',
13+
'ru',
14+
'zh_CN',
15+
'ro',
16+
'uk',
17+
'en',
18+
'bg'
19+
);
20+
21+
$number = 1234567.89;
22+
23+
$res_str = '';
24+
foreach( $locales as $locale )
25+
{
26+
$fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL_COMPACT_SHORT );
27+
$res_str .= "$locale: short = " . ut_nfmt_format ($fmt, $number) . "\n";
28+
29+
$fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL_COMPACT_LONG );
30+
$res_str .= "$locale: long = " . ut_nfmt_format ($fmt, $number) . "\n";
31+
}
32+
return $res_str;
33+
}
34+
35+
include_once( 'ut_common.inc' );
36+
37+
// Run the test
38+
ut_run();
39+
40+
?>
41+
--EXPECTF--
42+
en_UK: short = 1.2M
43+
en_UK: long = 1.2 million
44+
en_US: short = 1.2M
45+
en_US: long = 1.2 million
46+
ru: short = 1,2 млн
47+
ru: long = 1,2 миллиона
48+
zh_CN: short = 123万
49+
zh_CN: long = 123万
50+
ro: short = 1,2 mil.
51+
ro: long = 1,2 milioane
52+
uk: short = 1,2 млн
53+
uk: long = 1,2 мільйона
54+
en: short = 1.2M
55+
en: long = 1.2 million
56+
bg: short = 1,2 млн.
57+
bg: long = 1,2 милиона

0 commit comments

Comments
 (0)