Skip to content

Commit 8a4f327

Browse files
committed
sc2tcComb
1 parent 7258a71 commit 8a4f327

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Switch Traditional Chinese and Simplified Chinese/lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "switch-chinese",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Convert between simplified and traditional Chinese characters",
55
"main": "stcasc.lib.js",
66
"type": "module",

Switch Traditional Chinese and Simplified Chinese/lib/readme.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
+ 基礎用法
1111

1212
``` js
13+
import Stcasc from './stcasc.lib.js';
1314
const stcasc = Stcasc();
14-
const sc = "香烟 香烟袅袅 烟雾里 里长面子 吃干面 干 把考卷发回来 卷发";
15+
const sc = "香烟 香烟袅袅 烟雾里 里长面子 吃干面 干 把考卷发回来 卷发 知识产权";
1516
console.log(stcasc.traditionalized(sc));
16-
//香菸 香煙裊裊 煙霧裡 里長面子 吃乾麵 幹 把考卷發回來 捲髮
17+
//香菸 香煙裊裊 煙霧裡 里長面子 吃乾麵 幹 把考卷發回來 捲髮 智慧財產權
18+
```
19+
20+
``` js
21+
const stcasc = Stcasc({}, {}, true);
22+
const sc = "知识产权";
23+
console.log(stcasc.traditionalized(sc));
24+
//知識産權
1725
```
1826

1927
+ 透過 npm 安裝
@@ -56,3 +64,9 @@ const custom = {
5664
};
5765
let stcasc = Stcasc(cache, custom);
5866
```
67+
68+
+ 禁用用語轉換
69+
70+
``` js
71+
let stcasc = Stcasc({}, {}, true);
72+
```

Switch Traditional Chinese and Simplified Chinese/lib/stcasc.lib.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ const tc2sc = {
473473
['了','瞭望','瞭然','瞭解','瞭若指掌','瞭如指掌']
474474
]
475475
};
476-
const sc2tcComb = {
476+
let sc2tcComb = {
477477
'香烟袅袅':'香煙裊裊',
478478
'袅袅香烟':'裊裊香煙',
479479
'补丁':'補靪',
@@ -756,12 +756,13 @@ function simplized(orgStr) {
756756
return str;
757757
}
758758

759-
function Stcasc(cache, custom) {
759+
function Stcasc(cache, custom, disableTerms) {
760760
if (!cache) cache = {};
761761
if (cache.sc2tcCombTree && cache.tc2scCombTree) {
762762
sc2tcCombTree = cache.sc2tcCombTree;
763763
tc2scCombTree = cache.tc2scCombTree;
764764
} else {
765+
if (disableTerms) sc2tcComb = {};
765766
if (custom && custom.length) {
766767
for (let sc in custom) {
767768
sc2tcComb[sc] = custom[sc];

0 commit comments

Comments
 (0)