-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathhandleText.ts
54 lines (48 loc) · 1.26 KB
/
handleText.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
import { processIdeaSegmentText } from './segment';
import { updateMeta } from './meta';
import { textToRegexp } from './util/text-to-regexp';
import { textIncludeCJK } from './util/include-cjk';
export function handleText(content_old: string, info?: {
file?: string,
})
{
const file = info?.file ?? '';
return processIdeaSegmentText(content_old)
.then(content_new =>
{
if (/META-INF\/plugin\.xml$/i.test(file))
{
content_new = updateMeta(content_new);
}
else if (/(?:Git(?:hub)?|Vcs(?:Log)?|Svn|Diff)Bundle\.properties$/i.test(file))
{
content_new = content_new
.replace(/提取/g, '獲取')
.replace(/儲存庫/g, '版本庫')
.replace(/統一/g, '統合')
;
}
else if (/LeakableMapKey\.html$/i.test(file))
{
content_new = content_new
.replace(textToRegexp(/卸載|移除/g), '解除安裝')
;
}
else if (/(JavaScript|InspectionGadgets|Php)Bundle.properties$/i.test(file))
{
content_new = content_new
.replace(textToRegexp(/縮小/g), '限縮')
;
}
content_new = content_new
.replace(textToRegexp(/Java (?:运|執)行时(.)?/g), ($0, $1) => {
if (textIncludeCJK($1))
{
$1 = ' ' + $1;
}
return 'Java Runtime' + $1
})
;
return content_new
})
}