Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BBeretta
Neos
Commits
75b8dbfd
Commit
75b8dbfd
authored
May 14, 2024
by
BBeretta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prettier adoption added
parent
19a974ef
Pipeline
#27121
failed with stages
in 12 minutes and 20 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
59 deletions
+61
-59
src/Language/LanguageContext.tsx
src/Language/LanguageContext.tsx
+9
-5
src/Language/LanguageSelector.tsx
src/Language/LanguageSelector.tsx
+3
-3
src/i18n.tsx
src/i18n.tsx
+32
-34
src/main.tsx
src/main.tsx
+9
-9
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+3
-3
src/ui/Start/index.tsx
src/ui/Start/index.tsx
+5
-5
No files found.
src/Language/LanguageContext.tsx
View file @
75b8dbfd
import
React
,
{
createContext
,
useState
,
useContext
}
from
'
react
'
;
import
React
,
{
createContext
,
useState
,
useContext
}
from
"
react
"
;
interface
LanguageContextType
{
interface
LanguageContextType
{
language
:
string
;
language
:
string
;
changeLanguage
:
(
newLanguage
:
string
)
=>
void
;
changeLanguage
:
(
newLanguage
:
string
)
=>
void
;
}
}
const
LanguageContext
=
createContext
<
LanguageContextType
|
undefined
>
(
undefined
);
const
LanguageContext
=
createContext
<
LanguageContextType
|
undefined
>
(
undefined
,
);
export
const
LanguageProvider
:
React
.
FC
<
{
children
:
React
.
ReactNode
}
>
=
({
children
})
=>
{
export
const
LanguageProvider
:
React
.
FC
<
{
children
:
React
.
ReactNode
}
>
=
({
const
[
language
,
setLanguage
]
=
useState
<
string
>
(
'
cn
'
);
// default language
children
,
})
=>
{
const
[
language
,
setLanguage
]
=
useState
<
string
>
(
"
cn
"
);
const
changeLanguage
=
(
newLanguage
:
string
)
=>
{
const
changeLanguage
=
(
newLanguage
:
string
)
=>
{
setLanguage
(
newLanguage
);
setLanguage
(
newLanguage
);
...
@@ -24,7 +28,7 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil
...
@@ -24,7 +28,7 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil
export
const
useLanguage
=
():
LanguageContextType
=>
{
export
const
useLanguage
=
():
LanguageContextType
=>
{
const
context
=
useContext
(
LanguageContext
);
const
context
=
useContext
(
LanguageContext
);
if
(
!
context
)
{
if
(
!
context
)
{
throw
new
Error
(
'
useLanguage must be used within a LanguageProvider
'
);
throw
new
Error
(
"
useLanguage must be used within a LanguageProvider
"
);
}
}
return
context
;
return
context
;
};
};
src/Language/LanguageSelector.tsx
View file @
75b8dbfd
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
useEffect
}
from
"
react
"
;
import
{
useTranslation
}
from
'
react-i18next
'
;
import
{
useTranslation
}
from
"
react-i18next
"
;
const
LanguageSelector
:
React
.
FC
=
()
=>
{
const
LanguageSelector
:
React
.
FC
=
()
=>
{
const
{
t
,
i18n
}
=
useTranslation
();
const
{
t
,
i18n
}
=
useTranslation
();
...
@@ -7,7 +7,7 @@ const LanguageSelector: React.FC = () => {
...
@@ -7,7 +7,7 @@ const LanguageSelector: React.FC = () => {
const
onClickLanguageChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
onClickLanguageChange
=
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
language
=
e
.
target
.
value
;
const
language
=
e
.
target
.
value
;
i18n
.
changeLanguage
(
language
);
i18n
.
changeLanguage
(
language
);
console
.
log
(
'
Language::
'
,
language
);
console
.
log
(
"
Language::
"
,
language
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
src/i18n.tsx
View file @
75b8dbfd
...
@@ -27,39 +27,37 @@ import translationPortuguese from "./Translation/Portuguese/translation.json";
...
@@ -27,39 +27,37 @@ import translationPortuguese from "./Translation/Portuguese/translation.json";
const
resources
=
{
const
resources
=
{
cn
:
{
cn
:
{
Header
:
translationChinese
.
Header
,
Header
:
translationChinese
.
Header
,
Start
:
translationChinese
.
Start
Start
:
translationChinese
.
Start
,
},
},
en
:
{
en
:
{
Header
:
translationEnglish
.
Header
,
Header
:
translationEnglish
.
Header
,
Start
:
translationEnglish
.
Start
Start
:
translationEnglish
.
Start
,
},
},
es
:
{
es
:
{
Header
:
translationSpanish
.
Header
,
Header
:
translationSpanish
.
Header
,
Start
:
translationSpanish
.
Start
Start
:
translationSpanish
.
Start
,
},
},
fr
:
{
fr
:
{
Header
:
translationFrench
.
Header
,
Header
:
translationFrench
.
Header
,
Start
:
translationFrench
.
Start
Start
:
translationFrench
.
Start
,
},
},
jp
:
{
jp
:
{
Header
:
translationJapanese
.
Header
,
Header
:
translationJapanese
.
Header
,
Start
:
translationJapanese
.
Start
Start
:
translationJapanese
.
Start
,
},
},
br
:
{
br
:
{
Header
:
translationBrazilian
.
Header
,
Header
:
translationBrazilian
.
Header
,
Start
:
translationBrazilian
.
Start
Start
:
translationBrazilian
.
Start
,
},
},
pt
:
{
pt
:
{
Header
:
translationPortuguese
.
Header
,
Header
:
translationPortuguese
.
Header
,
Start
:
translationPortuguese
.
Start
Start
:
translationPortuguese
.
Start
,
},
},
}
}
;
i18next
i18next
.
use
(
initReactI18next
).
init
({
.
use
(
initReactI18next
)
.
init
({
resources
,
resources
,
lng
:
"
cn
"
,
//default language
lng
:
"
cn
"
,
//default language
});
});
export
default
i18next
;
export
default
i18next
;
src/main.tsx
View file @
75b8dbfd
...
@@ -29,9 +29,9 @@ import { theme } from "@/ui/theme";
...
@@ -29,9 +29,9 @@ import { theme } from "@/ui/theme";
import
{
NeosRouter
}
from
"
./ui/NeosRouter
"
;
import
{
NeosRouter
}
from
"
./ui/NeosRouter
"
;
import
'
./i18n
'
import
"
./i18n
"
;
import
{
LanguageProvider
}
from
'
./Language/LanguageContext
'
;
import
{
LanguageProvider
}
from
"
./Language/LanguageContext
"
;
const
root
=
ReactDOM
.
createRoot
(
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
"
root
"
)
as
HTMLElement
,
document
.
getElementById
(
"
root
"
)
as
HTMLElement
,
...
...
src/ui/Layout/index.tsx
View file @
75b8dbfd
...
@@ -61,7 +61,7 @@ const HeaderBtn: React.FC<
...
@@ -61,7 +61,7 @@ const HeaderBtn: React.FC<
};
};
export
const
Component
=
()
=>
{
export
const
Component
=
()
=>
{
const
{
t
}
=
useTranslation
(
'
Header
'
);
const
{
t
}
=
useTranslation
(
"
Header
"
);
// 捕获SSO登录
// 捕获SSO登录
const
routerLocation
=
useLocation
();
const
routerLocation
=
useLocation
();
...
...
src/ui/Start/index.tsx
View file @
75b8dbfd
...
@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
...
@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
export
const
Component
:
React
.
FC
=
()
=>
{
export
const
Component
:
React
.
FC
=
()
=>
{
const
{
t
}
=
useTranslation
(
'
Start
'
);
const
{
t
}
=
useTranslation
(
"
Start
"
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
return
(
return
(
...
@@ -50,7 +50,7 @@ export const Component: React.FC = () => {
...
@@ -50,7 +50,7 @@ export const Component: React.FC = () => {
Component
.
displayName
=
"
Start
"
;
Component
.
displayName
=
"
Start
"
;
const
LoginBtn
:
React
.
FC
<
{
logined
:
boolean
}
>
=
({
logined
})
=>
{
const
LoginBtn
:
React
.
FC
<
{
logined
:
boolean
}
>
=
({
logined
})
=>
{
const
{
t
}
=
useTranslation
(
'
Start
'
);
const
{
t
}
=
useTranslation
(
"
Start
"
);
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment