From 0d87d0fa28f56044304db1748e0b685b8867d3db Mon Sep 17 00:00:00 2001 From: kimatata <117462761+kimatata@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:39:55 +0900 Subject: [PATCH] chore: language order (#370) --- README.md | 4 +++- frontend/config/selection.ts | 9 +++++++-- frontend/messages/strings.test.ts | 11 ++++++----- frontend/src/i18n/routing.ts | 2 +- frontend/src/middleware.ts | 2 +- frontend/types/locale.ts | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 29e9fac..7681815 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,10 @@ Support team development by adding or removing members from projects. You can as UnitTCMS currently supports the following languages: +- German (de) - English (en) -- Japanese (ja) - Portuguese (pt-BR) +- Chinese (zh-CN) +- Japanese (ja) If you would like to add support for another language, feel free to submit a pull request. For reference, you can see how Portuguese was added in [PR #260](https://github.com/kimatata/unittcms/pull/260). diff --git a/frontend/config/selection.ts b/frontend/config/selection.ts index 660e97c..8b11215 100644 --- a/frontend/config/selection.ts +++ b/frontend/config/selection.ts @@ -9,12 +9,17 @@ const memberRoles: MemberRoleType[] = [{ uid: 'manager' }, { uid: 'developer' }, const categoricalPalette = ['#fba91e', '#6ea56c', '#3ac6e1', '#feda2f', '#f15f47', '#244470', '#9c80bb', '#f595a6']; +/** + * Locales are grouped by script: Latin-based locales first, followed by CJK. + * Within Latin-based group, entries are sorted lexicographically by their BCP 47 codes. + * This matches common UI patterns. + */ const locales: LocaleType[] = [ - { code: 'en', name: 'English' }, - { code: 'ja', name: '日本語' }, { code: 'de', name: 'Deutsch' }, + { code: 'en', name: 'English' }, { code: 'pt-BR', name: 'Português' }, { code: 'zh-CN', name: '简体中文' }, + { code: 'ja', name: '日本語' }, ]; // The status of each test run diff --git a/frontend/messages/strings.test.ts b/frontend/messages/strings.test.ts index 7f4e119..ef269f7 100644 --- a/frontend/messages/strings.test.ts +++ b/frontend/messages/strings.test.ts @@ -1,9 +1,9 @@ import { describe, it, expect } from 'vitest'; +import de from './de.json'; import en from './en.json'; -import ja from './ja.json'; import ptBR from './pt-BR.json'; import zhCN from './zh-CN.json'; -import de from './de.json'; +import ja from './ja.json'; function getAllKeys(obj: unknown, prefix = ''): string[] { if (typeof obj !== 'object' || obj === null) return []; @@ -18,14 +18,15 @@ function getAllKeys(obj: unknown, prefix = ''): string[] { describe('Locale message keys consistency', () => { const locales = [ + { name: 'de', data: de }, { name: 'en', data: en }, - { name: 'ja', data: ja }, { name: 'pt-BR', data: ptBR }, { name: 'zh-CN', data: zhCN }, - { name: 'de', data: de }, + { name: 'ja', data: ja }, ]; - const base = locales[0]; + const base = locales.find((locale) => locale.name === 'en'); + if (!base) throw new Error('Base locale not found'); const baseKeys = getAllKeys(base.data); for (const locale of locales.slice(1)) { diff --git a/frontend/src/i18n/routing.ts b/frontend/src/i18n/routing.ts index 5d96dc2..c09ac0e 100644 --- a/frontend/src/i18n/routing.ts +++ b/frontend/src/i18n/routing.ts @@ -2,7 +2,7 @@ import { createNavigation } from 'next-intl/navigation'; import { defineRouting } from 'next-intl/routing'; export const routing = defineRouting({ - locales: ['en', 'ja', 'pt-BR', 'zh-CN', 'de'], + locales: ['de', 'en', 'pt-BR', 'zh-CN', 'ja'], defaultLocale: 'en', localePrefix: { mode: 'always', diff --git a/frontend/src/middleware.ts b/frontend/src/middleware.ts index 9116a88..fa9af8c 100644 --- a/frontend/src/middleware.ts +++ b/frontend/src/middleware.ts @@ -4,5 +4,5 @@ import { routing } from './i18n/routing'; export default createMiddleware(routing); export const config = { - matcher: ['/', '/(ja|en|pt-BR|zh-CN|de)/:path*'], + matcher: ['/', '/(de|en|pt-BR|zh-CN|ja)/:path*'], }; diff --git a/frontend/types/locale.ts b/frontend/types/locale.ts index 909265a..e1d2270 100644 --- a/frontend/types/locale.ts +++ b/frontend/types/locale.ts @@ -1,4 +1,4 @@ -export type LocaleCodeType = 'en' | 'ja' | 'pt-BR' | 'zh-CN' | 'de'; +export type LocaleCodeType = 'de' | 'en' | 'pt-BR' | 'zh-CN' | 'ja'; export type LocaleType = { code: LocaleCodeType;