Locale.d.ts (4690B)
1 // generated by diplomat-tool 2 import type { LocaleParseError } from "./LocaleParseError" 3 import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; 4 5 6 /** 7 * An ICU4X Locale, capable of representing strings like `"en-US"`. 8 * 9 * See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html) for more information. 10 */ 11 12 13 export class Locale { 14 get ffiValue(): pointer; 15 16 17 /** 18 * Construct an [`Locale`] from an locale identifier. 19 * 20 * This will run the complete locale parsing algorithm. If code size and 21 * performance are critical and the locale is of a known shape (such as 22 * `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`. 23 * 24 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information. 25 */ 26 static fromString(name: string): Locale; 27 28 /** 29 * Construct a unknown [`Locale`] "und". 30 * 31 * See the [Rust documentation for `UNKNOWN`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#associatedconstant.UNKNOWN) for more information. 32 */ 33 static unknown(): Locale; 34 35 /** 36 * Clones the [`Locale`]. 37 * 38 * See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html) for more information. 39 */ 40 clone(): Locale; 41 42 /** 43 * Returns a string representation of the `LanguageIdentifier` part of 44 * [`Locale`]. 45 * 46 * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information. 47 */ 48 get basename(): string; 49 50 /** 51 * Returns a string representation of the unicode extension. 52 * 53 * See the [Rust documentation for `extensions`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.extensions) for more information. 54 */ 55 getUnicodeExtension(s: string): string | null; 56 57 /** 58 * Returns a string representation of [`Locale`] language. 59 * 60 * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information. 61 */ 62 get language(): string; 63 64 /** 65 * Set the language part of the [`Locale`]. 66 * 67 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information. 68 */ 69 set language(s: string); 70 71 /** 72 * Returns a string representation of [`Locale`] region. 73 * 74 * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information. 75 */ 76 get region(): string | null; 77 78 /** 79 * Set the region part of the [`Locale`]. 80 * 81 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information. 82 */ 83 set region(s: string); 84 85 /** 86 * Returns a string representation of [`Locale`] script. 87 * 88 * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#structfield.id) for more information. 89 */ 90 get script(): string | null; 91 92 /** 93 * Set the script part of the [`Locale`]. Pass an empty string to remove the script. 94 * 95 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.try_from_str) for more information. 96 */ 97 set script(s: string); 98 99 /** 100 * Normalizes a locale string. 101 * 102 * See the [Rust documentation for `normalize`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.normalize) for more information. 103 */ 104 static normalize(s: string): string; 105 106 /** 107 * Returns a string representation of [`Locale`]. 108 * 109 * See the [Rust documentation for `write_to`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.write_to) for more information. 110 */ 111 toString(): string; 112 113 /** 114 * See the [Rust documentation for `normalizing_eq`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.normalizing_eq) for more information. 115 */ 116 normalizingEq(other: string): boolean; 117 118 /** 119 * See the [Rust documentation for `strict_cmp`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.strict_cmp) for more information. 120 */ 121 compareToString(other: string): number; 122 123 /** 124 * See the [Rust documentation for `total_cmp`](https://docs.rs/icu/latest/icu/locale/struct.Locale.html#method.total_cmp) for more information. 125 */ 126 compareTo(other: Locale): number; 127 }