-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.ts
191 lines (174 loc) · 4.23 KB
/
types.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import type { ParseConfig } from 'papaparse'
import type { FilterPattern } from 'vite'
export interface Options {
/**
* Default sheetI18n include i18n.csv file only,
*
* You could use this template to include spreadsheets: /(?:\/|\\|^)i18n\.(?:[cdt]sv|xls[xmb]?|ods)$/
*
* @default /(?:\/|\\|^)i18n\.(?:[cdt]sv)$/
*/
include?: FilterPattern
/**
* @default undefined
*/
exclude?: FilterPattern
/**
* Output directory, same directory as source file if undefined
*
* @default undefined
*/
outDir?: string
/**
* Output file key style format
*
* @default 'flat'
*/
keyStyle?: 'flat' | 'nested'
/**
* Enable .xls[xmb]? and .ods support, multi-sheets is also supported,
*
* ie: sheetI18n will merge all sheets into one
*
* @default false
*/
xlsx?: boolean
/**
* Column name to use as key/id
*
* @default 'KEY'
*/
keyColumn?: string
/**
* By default sheetI18n will automatically parses and output fileName as localeId-alike columns (en, FR, vi-VN...),
*
* Defining a valueColumn will uses that column as value and output as same input fileName: `ha.csv => ha.json`
*
* @default undefined
*/
valueColumn?: string
/**
* The regular expression to match/detect locales columns
*
* @default /^\w{2}(?:-\w{2,4})?$/
*/
localesMatcher?: RegExp
/**
* Setting a custom delimiter for the dsv file, by default it's auto detected
*
* @default undefined // auto-detect
*/
delimiter?: ParseConfig['delimiter']
/**
* A string that indicates a comment (for example, "#" or "//").
*
* When the parser encounters a line starting with this string, it will skip the line.
*
* @default '//'
*/
comments?: false | string | string[]
/**
* Merge json output of processed files (if they output to same file)
*
* @default true
*/
mergeOutput?: boolean
/**
* Specify the output structure
*
* Requires `outDir` to be configured
*
* `'parent'`: `/a/i18n.csv` => `/a/en.json`
*
* `'nested'`: `/a/i18n.csv` => `/a/i18n/en.json`
*
* `'prefixed'`: `/a/i18n.csv` => `/a/i18n_en.json`
*
* `true` is same as `'parent'`
*
* @default false
*/
preserveStructure?: boolean | 'parent' | 'nested' | 'prefixed'
/**
* Replaces all spaces followed by a "high" punctuation with a non-breaking space, this is useful to fix ugly UI wrapping for cases like French that requires a space before the punctuations.
*
* Punctuations currently scan for is: !$%:;?+-
*
* @default true
*/
replacePunctuationSpace?: boolean
/**
* Enables special processing for $JSON keys
*
* Key syntax: `$JSON;[fileName];[selectors];[path];[key]`
*
* Example:
* ```txt
* For a key:
* $JSON;cloud;id:what;a.nested.path;display - What?
*
* We will get a file: cloud_[locale] with the content:
* """
* [
* {
* "__selectorKeys": [
* "id"
* ],
* "id": "what",
* "a": {
* "nested": {
* "path": {
* "i18n": {
* "en": {
* "display": "What?"
* }
* }
* }
* }
* }
* }
* ]
* """
* ```
*
* //TODO: add util for checking an object againts the outputted JSON array, util to load the internalization text from the outputted format
*
* jsonProcessor will always work in auto locale columns mode, and exported file will be 'flat'
*
* @default false
*/
jsonProcessor?: boolean
/**
* Filter $JSON keys from the normal processing logic
*
* Effective only if `jsonProcessor` is enabled
*
* @default true
*/
jsonProcessorClean?: boolean
/**
* Enables special processing for $FILE keys
*
* Key syntax: `$FILE;[fileName];[extension]`,
* extension is optional and defaults to 'txt'
*
* Example:
* ```txt
* For a key:
* $FILE;hi_there;md - Halo
*
* We will get a file: hi_there_[locale].md with the content: "Halo"
* ```
*
* @default false
*/
fileProcessor?: boolean
/**
* Filter $FILE keys from the normal processing logic
*
* Effective only if `fileProcessor` is enabled
*
* @default true
*/
fileProcessorClean?: boolean
}