UNPKG

1.55 kBTypeScriptView Raw
1export type Selector = string
2export interface LocationDetails {
3 offset: number
4 line: number
5 column: number
6}
7export interface Location {
8 start: LocationDetails,
9 end: LocationDetails
10}
11export interface SimpleFormat {
12 type: 'numberFormat' | 'dateFormat' | 'timeFormat'
13 style: string
14 location: Location
15}
16export interface PluralFormat extends PluralStyle {
17 ordinal: false
18}
19export interface SelectFormat {
20 type: 'selectFormat'
21 options: OptionalFormatPattern[],
22 location: Location
23}
24export interface SelectOrdinalFormat extends PluralStyle {
25 ordinal: true,
26}
27export type ElementFormat = SimpleFormat | PluralFormat | SelectOrdinalFormat | SelectFormat
28export interface OptionalFormatPattern {
29 type: 'optionalFormatPattern',
30 selector: Selector
31 value: MessageFormatPattern
32 location: Location
33}
34export interface PluralStyle {
35 type: 'pluralFormat',
36 offset: number
37 options: OptionalFormatPattern[],
38 location: Location
39}
40export interface MessageTextElement {
41 type: 'messageTextElement'
42 value: string
43 location: Location
44}
45export interface ArgumentElement {
46 type: 'argumentElement'
47 id: string
48 format: ElementFormat
49 location: Location
50}
51export type Element = MessageTextElement | ArgumentElement
52
53export interface MessageFormatPattern {
54 type: 'messageFormatPattern',
55 elements: Array<Element>,
56 location: Location
57}
58interface Parser {
59 parse (msg: string): MessageFormatPattern
60}
61declare const parser: Parser
62export default parser
\No newline at end of file