feat: localize default strategy names by UI language at registration

- Pass `lang` from register request body to createDefaultStrategies
- Support zh/en/id locales for strategy names and descriptions
- Wrap strategy creation in a transaction to prevent partial writes
- Frontend sends current UI language in register request body
- Strategy list UI: 2-line clamp, unselected border, larger spacing, smaller font for non-zh
This commit is contained in:
Dean
2026-03-27 21:11:12 +08:00
committed by shinchan-zhai
parent 39782600a9
commit 1d897f635e
3 changed files with 73 additions and 21 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ import { flushSync } from 'react-dom'
import { getSystemConfig } from '../lib/config'
import { reset401Flag, httpClient } from '../lib/httpClient'
import { getPostAuthPath, setUserMode, type UserMode } from '../lib/onboarding'
import { useLanguage } from './LanguageContext'
interface User {
id: string
@@ -41,6 +42,7 @@ interface AuthContextType {
const AuthContext = createContext<AuthContextType | undefined>(undefined)
export function AuthProvider({ children }: { children: React.ReactNode }) {
const { language } = useLanguage()
const [user, setUser] = useState<User | null>(null)
const [token, setToken] = useState<string | null>(null)
const [isLoading, setIsLoading] = useState(true)
@@ -208,7 +210,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
email: string
password: string
beta_code?: string
} = { email, password }
lang?: string
} = { email, password, lang: language }
if (betaCode) {
requestBody.beta_code = betaCode
}
+4 -4
View File
@@ -706,7 +706,7 @@ export function StrategyStudioPage() {
</button>
</div>
</div>
<div className="space-y-1">
<div className="space-y-2">
{strategies.map((strategy) => (
<div
key={strategy.id}
@@ -719,11 +719,11 @@ export function StrategyStudioPage() {
}}
className={`group px-2 py-2 rounded-lg cursor-pointer transition-all ${selectedStrategy?.id === strategy.id
? 'ring-1 ring-nofx-gold/50 bg-nofx-gold/10 shadow-[0_0_15px_rgba(240,185,11,0.1)]'
: 'hover:bg-nofx-bg-lighter/60 hover:ring-1 hover:ring-nofx-gold/20 bg-transparent'
: 'hover:bg-nofx-bg-lighter/60 ring-1 ring-white/10 hover:ring-nofx-gold/20 bg-transparent'
}`}
>
<div className="flex items-center justify-between">
<span className="text-sm truncate text-nofx-text">{strategy.name}</span>
<div className="flex items-start justify-between">
<span className={`line-clamp-2 text-nofx-text ${language === 'zh' ? 'text-sm' : 'text-xs'}`}>{strategy.name}</span>
<div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">
<button
onClick={(e) => { e.stopPropagation(); handleExportStrategy(strategy) }}