-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
45 lines (44 loc) · 1.38 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export * from '@i18n/__data'
export * from '@i18n/__state'
export * from './guess-locale'
export * from './interpolate'
export * from './localize'
export * from './makeKey'
export * from './load-translations'
export type Locale = string & {T?: 'Locale'}
export type Key = string & {T?: 'Key'}
/**
* A string matching `RegExp('^([^$]|\$[1-9$])*)*$')`, in other words, `$` is
* used to refer to parameters (max 9) or is escaped as `$$`
*/
export type Translation = string & {T?: 'Translation'}
/**
* The value of the param used to pick the plural. Use '*' for the fallback
* value
*/
export type Ordinal = string & {T?: 'Ordinal'}
type PluralTag = number | Ordinal
/**
* When the value is a number, it means to take the value of the tag with that
* number.
*
* Note that inlined Plural translations only work when used with the `plural`
* function. Runtime translations will work with both `plural` and `_`.
*/
export type Plural = {
'*': Translation | number
[tag: PluralTag]: Translation | number
}
/** The locale JSON file format */
export type Data = {
/** The locale key, e.g. `en_US` or `nl` */
locale: Locale
/** Try this locale for missing translations */
fallback?: Locale
/** The name of the locale in the locale, e.g. "Nederlands" */
name?: string
/** The translations, either strings with placeholders or plural objects */
translations: {
[key: Key]: Translation | Plural
}
}