From 8a0e5a03cc02cbf2a6821ddb8aad645b959b3e47 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 4 Oct 2024 06:57:03 +0800 Subject: [PATCH 1/3] add --- kumascript/macros/AvailableInWorkers.ejs | 62 ++++++++++++++++++------ 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/kumascript/macros/AvailableInWorkers.ejs b/kumascript/macros/AvailableInWorkers.ejs index 9d49f9e7a58c..367e313c8050 100644 --- a/kumascript/macros/AvailableInWorkers.ejs +++ b/kumascript/macros/AvailableInWorkers.ejs @@ -4,15 +4,20 @@ // Parameters: // // $0 - workerType (optional): -// 'window_and_dedicated': only in DedicatedWorker (and in Window) -// 'dedicated': only in DedicatedWorker +// null: (default) All workers (and in Window) +// 'worker': All workers (and no Window) // 'window_and_worker_except_service': all workers but ServiceWorker (and in Window) -// 'window_and_worker_except_shared': all workers but shared workers (and in Window) +// 'window_and_worker_except_shared': all workers but SharedWorker (and in Window) +// 'window_and_worker_except_dedicated': all workers but DedicatedWorker (and in Window) // 'worker_except_service': all workers but ServiceWorker (and no window) +// 'worker_except_shared': all workers but SharedWorker (and no window) +// 'worker_except_dedicated': all workers but DedicatedWorker (and no window) // 'window_and_service': only in ServiceWorker (and in Window) -// 'service': only in ServiceWorker -// 'worker': All workers (and no Window) -// null: (default) All workers (and in Window) +// 'window_and_shared': only in ServiceWorker (and in Window) +// 'window_and_dedicated': only in DedicatedWorker (and in Window) +// 'service': only in ServiceWorker (and no window) +// 'shared': only in SharedWorker (and no window) +// 'dedicated': only in DedicatedWorker (and no window) // // {{AvailableInWorkers}} // {{AvailableInWorkers("worker_except_service")}} @@ -60,22 +65,22 @@ const textNotShared = mdn.localString({ "zh-CN": `此特性在 Web Worker(不包括共享 Web Worker)中可用。`, }); +const textNotDedicated = mdn.localString({ + "en-US": `This feature is available in Web Workers, except for Dedicated Web Workers.`, +}); + const textNotServiceNotWindow = mdn.localString({ "en-US": `This feature is only available in Web Workers, except for Service Workers.`, "ja": `この機能はウェブワーカー内でのみ利用可能ですが、サービスワーカーでは使用できません。`, "zh-CN": `此特性仅在 Web Worker(不包括 Service Worker)中可用。`, }); -const textDedicated = mdn.localString({ - "en-US": `This feature is available in Dedicated Web Workers.`, - "ja": `この機能は専用ウェブワーカー内で利用可能です。`, - "zh-CN": `此特性在专用 Web Worker中可用。`, +const textNotSharedNotWindow = mdn.localString({ + "en-US": `This feature is only available in Web Workers, except for Shared Web Workers.`, }); -const textDedicatedOnly = mdn.localString({ - "en-US": `This feature is only available in Dedicated Web Workers.`, - "ja": `この機能は専用ウェブワーカー内でのみ利用可能です。`, - "zh-CN": `此特性仅在专用 Web Worker 中可用。`, +const textNotDedicatedNotWindow = mdn.localString({ + "en-US": `This feature is only available in Web Workers, except for Dedicated Web Workers.`, }); const textService = mdn.localString({ @@ -84,12 +89,32 @@ const textService = mdn.localString({ "zh-CN": `此特性在 Service Worker 中可用。`, }); +const textShared = mdn.localString({ + "en-US": `This feature is available in Shared Web Workers.`, +}); + +const textDedicated = mdn.localString({ + "en-US": `This feature is available in Dedicated Web Workers.`, + "ja": `この機能は専用ウェブワーカー内で利用可能です。`, + "zh-CN": `此特性在专用 Web Worker中可用。`, +}); + const textServiceOnly = mdn.localString({ "en-US": `This feature is only available in Service Workers.`, "ja": `この機能はサービスワーカー内でのみ利用可能です。`, "zh-CN": `此特性仅在 Service Worker 中可用。`, }) +const textSharedOnly = mdn.localString({ + "en-US": `This feature is only available in Shared Web Workers.`, +}) + +const textDedicatedOnly = mdn.localString({ + "en-US": `This feature is only available in Dedicated Web Workers.`, + "ja": `この機能は専用ウェブワーカー内でのみ利用可能です。`, + "zh-CN": `此特性仅在专用 Web Worker 中可用。`, +}); + const workerType = $0 || 'default'; const associatedText = { @@ -97,11 +122,16 @@ const associatedText = { worker: () => textWorker, window_and_worker_except_service: () => textNotService, window_and_worker_except_shared: () => textNotShared, + window_and_worker_except_dedicated: () => textNotDedicated, worker_except_service: () => textNotServiceNotWindow, - window_and_dedicated: () => textDedicated, - dedicated: () => textDedicatedOnly, + worker_except_shared: () => textNotSharedNotWindow, + worker_except_dedicated: () => textNotDedicatedNotWindow, window_and_service: () => textService, + window_and_shared: () => textShared, + window_and_dedicated: () => textDedicated, service: () => textServiceOnly, + shared: () => textSharedOnly, + dedicated: () => textDedicatedOnly, }; if (!associatedText[workerType]) { From cb8eece7a006548bd01d336d2b37ee0e6004fe51 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Mon, 7 Oct 2024 01:09:59 +0800 Subject: [PATCH 2/3] add zh-CN translation --- kumascript/macros/AvailableInWorkers.ejs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kumascript/macros/AvailableInWorkers.ejs b/kumascript/macros/AvailableInWorkers.ejs index 367e313c8050..654690402b2b 100644 --- a/kumascript/macros/AvailableInWorkers.ejs +++ b/kumascript/macros/AvailableInWorkers.ejs @@ -67,6 +67,7 @@ const textNotShared = mdn.localString({ const textNotDedicated = mdn.localString({ "en-US": `This feature is available in Web Workers, except for Dedicated Web Workers.`, + "zh-CN": `此特性在 Web Worker(不包括专用 Web Worker)中可用。`, }); const textNotServiceNotWindow = mdn.localString({ @@ -77,10 +78,12 @@ const textNotServiceNotWindow = mdn.localString({ const textNotSharedNotWindow = mdn.localString({ "en-US": `This feature is only available in Web Workers, except for Shared Web Workers.`, + "zh-CN": `此特性仅在 Web Worker(不包括共享 Web Worker)中可用。`, }); const textNotDedicatedNotWindow = mdn.localString({ "en-US": `This feature is only available in Web Workers, except for Dedicated Web Workers.`, + "zh-CN": `此特性仅在 Web Worker(不包括专用 Web Worker)中可用。`, }); const textService = mdn.localString({ @@ -91,6 +94,7 @@ const textService = mdn.localString({ const textShared = mdn.localString({ "en-US": `This feature is available in Shared Web Workers.`, + "zh-CN": `此特性在共享 Web Worker中可用。`, }); const textDedicated = mdn.localString({ @@ -107,6 +111,7 @@ const textServiceOnly = mdn.localString({ const textSharedOnly = mdn.localString({ "en-US": `This feature is only available in Shared Web Workers.`, + "zh-CN": `此特性仅在共享 Web Worker 中可用。`, }) const textDedicatedOnly = mdn.localString({ From 2add4f4cb8b1ff98fe0ac2ff22f9b19350f1bb0c Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:16:49 +0800 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: A1lo --- kumascript/macros/AvailableInWorkers.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kumascript/macros/AvailableInWorkers.ejs b/kumascript/macros/AvailableInWorkers.ejs index 654690402b2b..e5d46e7c28f3 100644 --- a/kumascript/macros/AvailableInWorkers.ejs +++ b/kumascript/macros/AvailableInWorkers.ejs @@ -94,13 +94,13 @@ const textService = mdn.localString({ const textShared = mdn.localString({ "en-US": `This feature is available in Shared Web Workers.`, - "zh-CN": `此特性在共享 Web Worker中可用。`, + "zh-CN": `此特性在共享 Web Worker 中可用。`, }); const textDedicated = mdn.localString({ "en-US": `This feature is available in Dedicated Web Workers.`, "ja": `この機能は専用ウェブワーカー内で利用可能です。`, - "zh-CN": `此特性在专用 Web Worker中可用。`, + "zh-CN": `此特性在专用 Web Worker 中可用。`, }); const textServiceOnly = mdn.localString({