mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix: default language improvement in activation page (#942)
This commit is contained in:
parent
062e2e915b
commit
b346bd9b83
|
@ -22,7 +22,7 @@ const validPassword = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/
|
||||||
|
|
||||||
const ActivateForm = () => {
|
const ActivateForm = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { locale } = useContext(I18n)
|
const { locale, setLocaleOnClient } = useContext(I18n)
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const workspaceID = searchParams.get('workspace_id')
|
const workspaceID = searchParams.get('workspace_id')
|
||||||
const email = searchParams.get('email')
|
const email = searchParams.get('email')
|
||||||
|
@ -45,6 +45,7 @@ const ActivateForm = () => {
|
||||||
const [timezone, setTimezone] = useState('Asia/Shanghai')
|
const [timezone, setTimezone] = useState('Asia/Shanghai')
|
||||||
const [language, setLanguage] = useState('en-US')
|
const [language, setLanguage] = useState('en-US')
|
||||||
const [showSuccess, setShowSuccess] = useState(false)
|
const [showSuccess, setShowSuccess] = useState(false)
|
||||||
|
const defaultLanguage = (navigator.language?.startsWith('zh') ? languageMaps['zh-Hans'] : languageMaps.en) || languageMaps.en
|
||||||
|
|
||||||
const showErrorMessage = (message: string) => {
|
const showErrorMessage = (message: string) => {
|
||||||
Toast.notify({
|
Toast.notify({
|
||||||
|
@ -83,6 +84,7 @@ const ActivateForm = () => {
|
||||||
timezone,
|
timezone,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
setLocaleOnClient(language.startsWith('en') ? 'en' : 'zh-Hans')
|
||||||
setShowSuccess(true)
|
setShowSuccess(true)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
@ -93,7 +95,7 @@ const ActivateForm = () => {
|
||||||
return (
|
return (
|
||||||
<div className={
|
<div className={
|
||||||
cn(
|
cn(
|
||||||
'flex flex-col items-center w-full grow items-center justify-center',
|
'flex flex-col items-center w-full grow justify-center',
|
||||||
'px-6',
|
'px-6',
|
||||||
'md:px-[108px]',
|
'md:px-[108px]',
|
||||||
)
|
)
|
||||||
|
@ -167,7 +169,7 @@ const ActivateForm = () => {
|
||||||
</label>
|
</label>
|
||||||
<div className="relative mt-1 rounded-md shadow-sm">
|
<div className="relative mt-1 rounded-md shadow-sm">
|
||||||
<SimpleSelect
|
<SimpleSelect
|
||||||
defaultValue={languageMaps.en}
|
defaultValue={defaultLanguage}
|
||||||
items={languages}
|
items={languages}
|
||||||
onSelect={(item) => {
|
onSelect={(item) => {
|
||||||
setLanguage(item.value as string)
|
setLanguage(item.value as string)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user