Skip to content

Commit

Permalink
add i18nLoader param (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
therockerline authored Mar 14, 2024
1 parent 3ad54dd commit c1047d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"watch:css": "npx tailwindcss -o ./dist/index.css --watch",
"build": "rm -rf ./dist && npm run build:css && rollup -c",
"build:css": "NODE_ENV=production npx tailwindcss -o ./dist/index.css --minify",
"build:win": "del /s /q dist && npm run build:wincss && rollup -c --configPlugin typescript",
"build:wincss": "set NODE_ENV=production npx tailwindcss -o ./dist/index.css --minify",
"build:widget": "parcel build ./src/index.widget.tsx --no-source-maps",
"serve:widget": "rm -rf ./widget-example/static/* && cp -rf ./dist-widget/* ./widget-example/static && npx http-server ./widget-example -o -c-1",
"build-storybook": "build-storybook -s public",
Expand Down Expand Up @@ -133,4 +135,4 @@
"webpack": "^5.74.0"
},
"license": "GPL-3.0-or-later"
}
}
5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { checkDarkTheme, setTheme } from './lib/darkTheme'

interface PhoneIslandProps {
dataConfig: string
i18nLoader?: () => void
showAlways?: boolean
}

interface DeviceInputOutputTypes {
deviceId: string
}

export const PhoneIsland: FC<PhoneIslandProps> = ({ dataConfig, showAlways = false }) => {
export const PhoneIsland: FC<PhoneIslandProps> = ({ dataConfig, i18nLoader = undefined, showAlways = false }: PhoneIslandProps) => {
const CONFIG: string[] = Base64.atob(dataConfig || '').split(':')
const HOST_NAME: string = CONFIG[0]
const USERNAME: string = CONFIG[1]
Expand Down Expand Up @@ -108,7 +109,7 @@ export const PhoneIsland: FC<PhoneIslandProps> = ({ dataConfig, showAlways = fal
//initialize i18n
useEffect(() => {
if (firstRenderI18n) {
loadI18n()
i18nLoader ? i18nLoader() : loadI18n()
setFirstRenderI18n(false)
}
}, [firstRenderI18n])
Expand Down

0 comments on commit c1047d1

Please sign in to comment.