mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-19 14:16:29 +00:00
feat(i18n): add Korean locale (#531)
Add a Korean message catalog covering every key in the English catalog, with placeholders matching English for each message. Register ko in the inlang project, accept it as a sign-up and saved user locale, and offer it in the sign-up language switch and the team settings language select. Co-authored-by: phj1081 <5908832+phj1081@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
phj1081
Claude
parent
2be1093b91
commit
d255e76806
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
### Added
|
||||
|
||||
- **i18n**: Add Korean as a display language, selectable on the sign-up page and in team settings.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **cli**: Fix release publication failing to find staged standalone downloads.
|
||||
|
||||
@@ -20,43 +20,46 @@ describe('Auth Signup Locale Hook', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('should save locale metadata for the user upon signup', async () => {
|
||||
const email = `signup-locale-${Date.now()}@example.com`
|
||||
it.each(['zh', 'ko'])(
|
||||
'should save %s locale metadata for the user upon signup',
|
||||
async (locale) => {
|
||||
const email = `signup-locale-${locale}-${Date.now()}@example.com`
|
||||
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'Locale Tester',
|
||||
locale: 'zh',
|
||||
},
|
||||
})
|
||||
// We must use any here because 'locale' is a custom property we extract in
|
||||
// our auth hooks, but better-auth's signUpEmail typescript interface does
|
||||
// not recognize it.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = await (auth.api.signUpEmail as any)({
|
||||
headers: new Headers(),
|
||||
body: {
|
||||
email,
|
||||
password: 'testpassword',
|
||||
name: 'Locale Tester',
|
||||
locale,
|
||||
},
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR:', res.error)
|
||||
}
|
||||
if (res.error) {
|
||||
console.error('SIGNUP ERROR:', res.error)
|
||||
}
|
||||
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
expect(res.user.email).toBe(email)
|
||||
expect(res).toBeDefined()
|
||||
expect(res.user).toBeDefined()
|
||||
expect(res.user.email).toBe(email)
|
||||
|
||||
// Check that the userMetadata record was created with key 'locale' and value 'zh'
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
// Check that the userMetadata record was created with key 'locale' and the requested value
|
||||
const teamMembers = await prisma.teamMember.findMany({
|
||||
where: { userId: res.user.id },
|
||||
})
|
||||
expect(teamMembers.length).toBeGreaterThan(0)
|
||||
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeDefined()
|
||||
expect(meta?.value).toBe('zh')
|
||||
}
|
||||
})
|
||||
for (const member of teamMembers) {
|
||||
const meta = await userMetadataService.getMetadata(res.user.id, member.teamId, 'locale')
|
||||
expect(meta).toBeDefined()
|
||||
expect(meta?.value).toBe(locale)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
it('should not save locale metadata if locale is invalid or missing', async () => {
|
||||
const email = `signup-no-locale-${Date.now()}@example.com`
|
||||
|
||||
@@ -201,7 +201,7 @@ export const auth = betterAuth({
|
||||
}
|
||||
|
||||
const locale = body?.locale
|
||||
if (locale === 'en' || locale === 'zh') {
|
||||
if (locale === 'en' || locale === 'zh' || locale === 'ko') {
|
||||
const joinedTeams = await prisma.teamMember.findMany({
|
||||
where: { userId: user.id },
|
||||
select: { teamId: true },
|
||||
|
||||
@@ -241,6 +241,7 @@
|
||||
"select_language": "Select Language",
|
||||
"english": "English",
|
||||
"chinese": "简体中文 (Chinese)",
|
||||
"korean": "한국어 (Korean)",
|
||||
"language_updated": "Language updated successfully",
|
||||
"failed_update_language": "Failed to update language",
|
||||
"avatar_updated": "Avatar updated successfully",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -241,6 +241,7 @@
|
||||
"select_language": "选择语言",
|
||||
"english": "English",
|
||||
"chinese": "简体中文 (Chinese)",
|
||||
"korean": "한국어 (Korean)",
|
||||
"language_updated": "语言更新成功",
|
||||
"failed_update_language": "语言更新失败",
|
||||
"avatar_updated": "头像更新成功",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/project-settings",
|
||||
"baseLocale": "en",
|
||||
"locales": ["en", "zh"],
|
||||
"locales": ["en", "zh", "ko"],
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"
|
||||
|
||||
@@ -199,7 +199,10 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
|
||||
try {
|
||||
await fetchMetadata(teamId)
|
||||
const savedLocale = getMetadata<string>('locale')
|
||||
if ((savedLocale === 'en' || savedLocale === 'zh') && savedLocale !== getLocale()) {
|
||||
if (
|
||||
(savedLocale === 'en' || savedLocale === 'zh' || savedLocale === 'ko') &&
|
||||
savedLocale !== getLocale()
|
||||
) {
|
||||
setLocale(savedLocale, { reload: false })
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -31,12 +31,12 @@ function SignupPage() {
|
||||
const inviteCode = (search as { inviteCode?: string }).inviteCode
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh'>(() => {
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh' | 'ko'>(() => {
|
||||
const activeLocale = getLocale()
|
||||
return activeLocale === 'zh' ? 'zh' : 'en'
|
||||
return activeLocale === 'zh' || activeLocale === 'ko' ? activeLocale : 'en'
|
||||
})
|
||||
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh') => {
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh' | 'ko') => {
|
||||
setLocaleState(newLocale)
|
||||
setLocale(newLocale)
|
||||
}
|
||||
@@ -280,6 +280,16 @@ function SignupPage() {
|
||||
>
|
||||
中文
|
||||
</button>
|
||||
<span className="text-zinc-300 dark:text-zinc-850">/</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('ko')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'ko' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
한국어
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
|
||||
@@ -254,7 +254,7 @@ export function TeamSettingsPage() {
|
||||
const currentLocale = getMetadata<string>('locale') || getLocale()
|
||||
|
||||
const handleLanguageChange = async (newLocale: string) => {
|
||||
if (newLocale === 'en' || newLocale === 'zh') {
|
||||
if (newLocale === 'en' || newLocale === 'zh' || newLocale === 'ko') {
|
||||
try {
|
||||
await setMetadata(teamId, 'locale', newLocale)
|
||||
setLocale(newLocale)
|
||||
@@ -957,6 +957,7 @@ export function TeamSettingsPage() {
|
||||
<SelectContent>
|
||||
<SelectItem value="en">{m.english()}</SelectItem>
|
||||
<SelectItem value="zh">{m.chinese()}</SelectItem>
|
||||
<SelectItem value="ko">{m.korean()}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user