55 License ,
66} from 'license-filter' ;
77import { observer } from 'mobx-react' ;
8+ import { GetServerSidePropsContext } from 'next' ;
9+ import { cache , compose , errorLogger } from 'next-ssr-middleware' ;
810import { FC , useContext , useEffect , useState } from 'react' ;
911import {
1012 Accordion ,
@@ -16,7 +18,17 @@ import {
1618
1719import { PageHead } from '../components/Layout/PageHead' ;
1820import { licenseTips , optionValue } from '../components/License/helper' ;
19- import { i18n , I18nContext } from '../models/Translation' ;
21+ import { i18n , I18nContext , I18nProps , loadSSRLanguage } from '../models/Translation' ;
22+
23+ export const getServerSideProps = compose ( cache ( ) , errorLogger , async ( context : GetServerSidePropsContext ) => {
24+ const ssrData = await loadSSRLanguage ( context as any ) ;
25+
26+ return {
27+ props : JSON . parse ( JSON . stringify ( {
28+ ...ssrData ,
29+ } ) ) ,
30+ } ;
31+ } ) ;
2032
2133interface List {
2234 license : License ;
@@ -36,7 +48,7 @@ const choiceSteps = [
3648 'marketingEndorsement' ,
3749] as const ;
3850
39- const LicenseTool : FC = observer ( ( ) => {
51+ const LicenseTool : FC < I18nProps > = observer ( ( ) => {
4052 const i18n = useContext ( I18nContext ) ;
4153 const { t } = i18n ;
4254
@@ -109,7 +121,19 @@ const LicenseTool: FC = observer(() => {
109121 className = "mb-3"
110122 variant = "info"
111123 now = { ( keyIndex + 1 ) * now }
112- label = { t ( 'step_x' , { step : keyIndex + 1 } ) }
124+ label = { ( ( ) => {
125+ const currentLang = i18n . currentLanguage ;
126+ const stepNumber = keyIndex + 1 ;
127+
128+ switch ( currentLang ) {
129+ case 'zh-CN' :
130+ case 'zh-TW' :
131+ return `第 ${ stepNumber } 步` ;
132+ case 'en-US' :
133+ default :
134+ return `step ${ stepNumber } ` ;
135+ }
136+ } ) ( ) }
113137 />
114138 < Button className = "mb-2" variant = "warning" onClick = { backToLast } >
115139 { t ( 'last_step' ) }
0 commit comments