Skip to content

Commit

Permalink
refactor: refactor entry point and improve code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo-ds committed Mar 16, 2024
1 parent 8cf9d99 commit 61bf62c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: build-script build-installer compress sha256sum

build-script:
@esbuild vcc-auto-translate.ts --bundle --minify --format=iife --platform=browser --outfile=cmd/installer/vcc-auto-translate.js
@esbuild src/index.ts --bundle --minify --format=iife --platform=browser --outfile=cmd/installer/vcc-auto-translate.js

build-installer: build-script
@mkdir -p build
Expand Down
8 changes: 5 additions & 3 deletions vcc-auto-translate.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zhHans from './localization/zh-hans.json'
import zhHant from './localization/zh-hant.json'
import zhHans from '../localization/zh-hans.json'
import zhHant from '../localization/zh-hant.json'
const debug_mode = localStorage.getItem('vcc_auto_translate_debug') === 'true'
const supported_languages = {
'zh-CN': zhHans,
Expand Down Expand Up @@ -56,7 +56,7 @@ function tr(s: string) {
const text = localization[s]
return [text !== undefined, text ?? s]
}
globalThis['vcc_auto_translate'] = (e: any, t: any) => {
export function vcc_auto_translate(e: any, t: any) {
if (!localization) return t
if (!e) return t
const element_name = typeof e === 'string' ? e : e.displayName
Expand Down Expand Up @@ -115,3 +115,5 @@ globalThis['vcc_auto_translate'] = (e: any, t: any) => {
: { whiteSpace: 'nowrap' }
return t
}

globalThis.vcc_auto_translate = vcc_auto_translate

0 comments on commit 61bf62c

Please sign in to comment.