From 9dc1d8a74b09181c70cf8e18443e15ae413ccf2e Mon Sep 17 00:00:00 2001 From: bluelovers Date: Wed, 26 Jan 2022 02:40:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=20git=20=E6=AA=94=E6=A1=88?= =?UTF-8?q?=E5=85=A7=E5=B0=87=20{=20=E6=8F=90=E5=8F=96=20=3D>=20=E7=8D=B2?= =?UTF-8?q?=E5=8F=96=20}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/handleText.ts | 26 ++++++++++++++++++++++++++ scripts/to-zht.ts | 8 ++------ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 lib/handleText.ts diff --git a/lib/handleText.ts b/lib/handleText.ts new file mode 100644 index 000000000..13a256f2f --- /dev/null +++ b/lib/handleText.ts @@ -0,0 +1,26 @@ +import { processIdeaSegmentText } from './segment'; +import { updateMeta } from './meta'; + +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 (/GitBundle.properties$/i.test(file)) + { + content_new + .replace(/提取/g, '獲取') + ; + } + + return content_new + }) +} diff --git a/scripts/to-zht.ts b/scripts/to-zht.ts index e5f55040a..ea3fc07e7 100644 --- a/scripts/to-zht.ts +++ b/scripts/to-zht.ts @@ -13,6 +13,7 @@ import { gray, red } from 'ansi-colors'; import { updateMeta } from '../lib/meta'; import { processIdeaSegmentText } from '../lib/segment'; import { array_unique_overwrite } from 'array-hyper-unique'; +import { handleText } from '../lib/handleText'; const multibar = createMultiBar(); @@ -62,12 +63,7 @@ export default FastGlob([ { const content_old = await readFile(fullpath).then(content => content.toString()); - let content_new = await processIdeaSegmentText(content_old); - - if (/META-INF\/plugin\.xml$/i.test(file)) - { - content_new = updateMeta(content_new); - } + let content_new = await handleText(content_old); if (content_new !== content_old) {