11/*
2- * Copyright (c) 2018, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
4949import org .graalvm .shadowed .com .ibm .icu .number .LocalizedNumberFormatter ;
5050import org .graalvm .shadowed .com .ibm .icu .number .LocalizedNumberRangeFormatter ;
5151import org .graalvm .shadowed .com .ibm .icu .number .NumberRangeFormatter ;
52+ import org .graalvm .shadowed .com .ibm .icu .number .UnlocalizedNumberFormatter ;
5253import org .graalvm .shadowed .com .ibm .icu .text .PluralRules ;
5354import org .graalvm .shadowed .com .ibm .icu .text .PluralRules .PluralType ;
5455
@@ -150,13 +151,15 @@ public static class InternalState extends JSNumberFormat.BasicInternalState {
150151 private LocalizedNumberRangeFormatter numberRangeFormatter ;
151152
152153 private String type ;
154+ private String notation ;
153155 private PluralRules pluralRules ;
154156 private final List <TruffleString > pluralCategories = new LinkedList <>();
155157
156158 @ Override
157159 void fillResolvedOptions (JSContext context , JSRealm realm , JSDynamicObject result ) {
158160 JSObjectUtil .putDataProperty (result , IntlUtil .KEY_LOCALE , Strings .fromJavaString (getLocale ()), JSAttributes .getDefault ());
159161 JSObjectUtil .putDataProperty (result , IntlUtil .KEY_TYPE , Strings .fromJavaString (type ), JSAttributes .getDefault ());
162+ JSObjectUtil .putDataProperty (result , IntlUtil .KEY_NOTATION , Strings .fromJavaString (notation ), JSAttributes .getDefault ());
160163 super .fillBasicResolvedOptions (result );
161164 JSObjectUtil .putDataProperty (result , IntlUtil .KEY_PLURAL_CATEGORIES , JSRuntime .createArrayFromList (realm .getContext (), realm , pluralCategories ), JSAttributes .getDefault ());
162165 super .fillRoundingResolvedOptions (result );
@@ -177,8 +180,10 @@ public void initializePluralRules() {
177180 @ TruffleBoundary
178181 public void initializeNumberFormatter () {
179182 super .initializeNumberFormatter ();
180- numberFormatter = getUnlocalizedFormatter ().locale (getJavaLocale ());
181- numberRangeFormatter = NumberRangeFormatter .withLocale (getJavaLocale ()).numberFormatterBoth (getUnlocalizedFormatter ());
183+ UnlocalizedNumberFormatter formatter = getUnlocalizedFormatter ();
184+ formatter = formatter .notation (JSNumberFormat .notationToICUNotation (notation , IntlUtil .LONG ));
185+ numberFormatter = formatter .locale (getJavaLocale ());
186+ numberRangeFormatter = NumberRangeFormatter .withLocale (getJavaLocale ()).numberFormatterBoth (formatter );
182187 }
183188
184189 public PluralRules getPluralRules () {
@@ -196,6 +201,10 @@ public LocalizedNumberRangeFormatter getNumberRangeFormatter() {
196201 public void setType (String type ) {
197202 this .type = type ;
198203 }
204+
205+ public void setNotation (String notation ) {
206+ this .notation = notation ;
207+ }
199208 }
200209
201210 @ TruffleBoundary
0 commit comments