1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * Provides internationalization related APIs. 18 * 19 * @since 6 20 * @devices phone, tablet, tv, wearable, car 21 */ 22declare namespace intl { 23/** 24 * Provides APIs for obtaining locale information. 25 * 26 * @since 6 27 */ 28export class Locale { 29 /** 30 * A constructor used to create a Locale object. 31 * 32 * @param locale Indicates a character string containing the locale information, including 33 * the language and optionally the script and region. 34 * @since 6 35 */ 36 constructor(locale?: string); 37 38 /** 39 * Indicates the language of the locale. 40 * 41 * @since 6 42 */ 43 language: string 44 45 /** 46 * Indicates the script of the locale. 47 * 48 * @since 6 49 */ 50 script: string 51 52 /** 53 * Indicates the region of the locale. 54 * 55 * @since 6 56 */ 57 region: string 58 59 /** 60 * Indicates the basic locale information, which is returned as a substring of 61 * a complete locale string. 62 * 63 * @since 6 64 */ 65 baseName: string 66 67 /** 68 * Indicates the case first style of the locale. 69 */ 70 caseFirst: string 71 72 /** 73 * Indicates the calendar. 74 */ 75 calendar: string 76 77 /** 78 * Indicates the collation. 79 */ 80 collation: string 81 82 /** 83 * Indicates the hour cycle. 84 */ 85 hourCycle: string 86 87 /** 88 * Indicates the numbering system. 89 */ 90 numberingSystem: string 91 92 /** 93 * Indicates whether it is numeric. 94 */ 95 numeric: boolean 96 97 /** 98 * Convert the locale information to string. 99 * 100 * @return Returns locale information in string form. 101 */ 102 toString(): string; 103 104 /** 105 * Maximize the locale's base information. 106 * 107 * @return Returns maximized locale. 108 */ 109 maximize(): Locale; 110 111 /** 112 * Minimize the locale's base information. 113 * 114 * @return Returns minimized locale. 115 */ 116 minimize(): Locale; 117} 118 119/** 120 * Provides the options of date time format. 121 */ 122export interface DateTimeOptions { 123 /** 124 * Indicates the locale. 125 */ 126 locale: string 127 128 /** 129 * Indicates the date style. 130 */ 131 dateStyle: string 132 133 /** 134 * Indicates the time style. 135 */ 136 timeStyle: string 137 138 /** 139 * Indicates the hour cycle. 140 */ 141 hourCycle: string 142 143 /** 144 * Indicates the timezone. 145 */ 146 timeZone: string 147 148 /** 149 * Indicates the numbering system. 150 */ 151 numberingSystem: string 152 153 /** 154 * Indicates whether is 12 hour or not. 155 */ 156 hour12: boolean 157 158 /** 159 * Indicates the weekday style. 160 */ 161 weekday: string 162 163 /** 164 * Indicates the era style. 165 */ 166 era: string 167 168 /** 169 * Indicates the year style. 170 */ 171 year: string 172 173 /** 174 * Indicates the month style. 175 */ 176 month: string 177 178 /** 179 * Indicates the day style. 180 */ 181 day: string 182 183 /** 184 * Indicates the hour style. 185 */ 186 hour: string 187 188 /** 189 * Indicates the minute style. 190 */ 191 minute: string 192 193 /** 194 * Indicates the second style. 195 */ 196 second: string 197 198 /** 199 * Indicates the timezone name. 200 */ 201 timeZoneName: string 202 203 /** 204 * Indicates the day period format. 205 */ 206 dayPeriod: string 207 208 /** 209 * Indicates the locale matching algorithm. 210 */ 211 localeMatcher: string 212 213 /** 214 * Indicates the format matching algorithm. 215 */ 216 formatMatcher: string 217} 218 219/** 220 * Provides the API for formatting date strings. 221 * 222 * @since 6 223 */ 224export class DateTimeFormat { 225 /** 226 * A constructor used to create a DateTimeFormat object. 227 * 228 * @param locale Indicates a character string containing the locale information, including 229 * the language and optionally the script and region, for the DateTimeFormat object. 230 * @param options Indicates the options used to format the date. 231 * @since 6 232 */ 233 constructor(locale: string, options?: DateTimeOptions); 234 235 /** 236 * A constructor used to create a DateTimeFormat object. 237 * 238 * @param locale Indicates an array of character string containing the locale information, including 239 * the language and optionally the script and region, for the DateTimeFormat object. 240 * @param options Indicates the options used to format the date. 241 * @since 6 242 */ 243 constructor(locale: Array<string>, options?: DateTimeOptions); 244 245 /** 246 * Obtains the formatted date strings. 247 * 248 * @param date Indicates the Date object to be formatted. 249 * @return Returns a date string formatted based on the specified locale. 250 * @since 6 251 */ 252 format(date: Date): string; 253 254 /** 255 * Obtains the formatted date strings of a date range. 256 * 257 * @param startDate Indicates the start date of the date range. 258 * @param endDate Indicates the end date of the date range. 259 * @return Returns a date string formatted based on the specified locale. 260 * @since 6 261 */ 262 formatRange(startDate: Date, endDate: Date): string; 263 264 /** 265 * Obtains the options of the DateTimeFormat object. 266 * 267 * @return Returns the options of the DateTimeFormat object. 268 * @since 6 269 */ 270 resolvedOptions(): DateTimeOptions; 271} 272 273/** 274 * Provides the options of number format. 275 */ 276export interface NumberOptions { 277 /** 278 * Indicates the locale. 279 */ 280 locale: string 281 282 /** 283 * Indicates the currency. 284 */ 285 currency: string 286 287 /** 288 * Indicates the currency sign. 289 */ 290 currencySign: string 291 292 /** 293 * Indicates the currency display format. 294 */ 295 currencyDisplay: string 296 297 /** 298 * Indicates the unit. 299 */ 300 unit: string 301 302 /** 303 * Indicates the unit display format. 304 */ 305 unitDisplay: string 306 307 /** 308 * Indicates the sign display format. 309 */ 310 signDisplay: string 311 312 /** 313 * Indicates the compact display format. 314 */ 315 compactDisplay: string 316 317 /** 318 * Indicates the notation. 319 */ 320 notation: string 321 322 /** 323 * Indicates the locale matching algorithm. 324 */ 325 localeMatcher: string 326 327 /** 328 * Indicates the style. 329 */ 330 style: string 331 332 /** 333 * Indicates the numbering system. 334 */ 335 numberingSystem: string 336 337 /** 338 * Indicates whether using grouping or not. 339 */ 340 useGrouping: boolean 341 342 /** 343 * Indicates the minimum integer digits. 344 */ 345 minimumIntegerDigits: number 346 347 /** 348 * Indicates the minimum fraction digits. 349 */ 350 minimumFractionDigits: number 351 352 /** 353 * Indicates the maximum fraction digits. 354 */ 355 maximumFractionDigits: number 356 357 /** 358 * Indicates the minimum significant digits. 359 */ 360 minimumSignificantDigits: number 361 362 /** 363 * Indicates the maximum significant digits. 364 */ 365 maximumSignificantDigits: number 366} 367 368/** 369 * Provides the API for formatting number strings. 370 */ 371export class NumberFormat { 372 /** 373 * A constructor used to create a NumberFormat object. 374 * 375 * @param locale Indicates a character string containing the locale information, including 376 * the language and optionally the script and region, for the NumberFormat object. 377 * @param options Indicates the options used to format the number. 378 * @since 6 379 */ 380 constructor(locale: string, options?: NumberOptions); 381 382 /** 383 * A constructor used to create a NumberFormat object. 384 * 385 * @param locale Indicates an array of character string containing the locale information, including 386 * the language and optionally the script and region, for the NumberFormat object. 387 * @param options Indicates the options used to format the number. 388 * @since 6 389 */ 390 constructor(locale: Array<string>, options?: NumberOptions); 391 392 /** 393 * Obtains the formatted number string. 394 * 395 * @param number Indicates the number to be formatted. 396 * @return Returns a number string formatted based on the specified locale. 397 * @since 6 398 */ 399 format(number: number): string; 400 401 /** 402 * Obtains the options of the NumberFormat object. 403 * 404 * @return Returns the options of the NumberFormat object. 405 * @since 6 406 */ 407 resolvedOptions(): NumberOptions; 408} 409} 410export default intl;