chore: language order (#370)
This commit is contained in:
@@ -83,8 +83,10 @@ Support team development by adding or removing members from projects. You can as
|
|||||||
|
|
||||||
UnitTCMS currently supports the following languages:
|
UnitTCMS currently supports the following languages:
|
||||||
|
|
||||||
|
- German (de)
|
||||||
- English (en)
|
- English (en)
|
||||||
- Japanese (ja)
|
|
||||||
- Portuguese (pt-BR)
|
- 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).
|
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).
|
||||||
|
|||||||
@@ -9,12 +9,17 @@ const memberRoles: MemberRoleType[] = [{ uid: 'manager' }, { uid: 'developer' },
|
|||||||
|
|
||||||
const categoricalPalette = ['#fba91e', '#6ea56c', '#3ac6e1', '#feda2f', '#f15f47', '#244470', '#9c80bb', '#f595a6'];
|
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[] = [
|
const locales: LocaleType[] = [
|
||||||
{ code: 'en', name: 'English' },
|
|
||||||
{ code: 'ja', name: '日本語' },
|
|
||||||
{ code: 'de', name: 'Deutsch' },
|
{ code: 'de', name: 'Deutsch' },
|
||||||
|
{ code: 'en', name: 'English' },
|
||||||
{ code: 'pt-BR', name: 'Português' },
|
{ code: 'pt-BR', name: 'Português' },
|
||||||
{ code: 'zh-CN', name: '简体中文' },
|
{ code: 'zh-CN', name: '简体中文' },
|
||||||
|
{ code: 'ja', name: '日本語' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// The status of each test run
|
// The status of each test run
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import de from './de.json';
|
||||||
import en from './en.json';
|
import en from './en.json';
|
||||||
import ja from './ja.json';
|
|
||||||
import ptBR from './pt-BR.json';
|
import ptBR from './pt-BR.json';
|
||||||
import zhCN from './zh-CN.json';
|
import zhCN from './zh-CN.json';
|
||||||
import de from './de.json';
|
import ja from './ja.json';
|
||||||
|
|
||||||
function getAllKeys(obj: unknown, prefix = ''): string[] {
|
function getAllKeys(obj: unknown, prefix = ''): string[] {
|
||||||
if (typeof obj !== 'object' || obj === null) return [];
|
if (typeof obj !== 'object' || obj === null) return [];
|
||||||
@@ -18,14 +18,15 @@ function getAllKeys(obj: unknown, prefix = ''): string[] {
|
|||||||
|
|
||||||
describe('Locale message keys consistency', () => {
|
describe('Locale message keys consistency', () => {
|
||||||
const locales = [
|
const locales = [
|
||||||
|
{ name: 'de', data: de },
|
||||||
{ name: 'en', data: en },
|
{ name: 'en', data: en },
|
||||||
{ name: 'ja', data: ja },
|
|
||||||
{ name: 'pt-BR', data: ptBR },
|
{ name: 'pt-BR', data: ptBR },
|
||||||
{ name: 'zh-CN', data: zhCN },
|
{ 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);
|
const baseKeys = getAllKeys(base.data);
|
||||||
|
|
||||||
for (const locale of locales.slice(1)) {
|
for (const locale of locales.slice(1)) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { createNavigation } from 'next-intl/navigation';
|
|||||||
import { defineRouting } from 'next-intl/routing';
|
import { defineRouting } from 'next-intl/routing';
|
||||||
|
|
||||||
export const routing = defineRouting({
|
export const routing = defineRouting({
|
||||||
locales: ['en', 'ja', 'pt-BR', 'zh-CN', 'de'],
|
locales: ['de', 'en', 'pt-BR', 'zh-CN', 'ja'],
|
||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
localePrefix: {
|
localePrefix: {
|
||||||
mode: 'always',
|
mode: 'always',
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ import { routing } from './i18n/routing';
|
|||||||
export default createMiddleware(routing);
|
export default createMiddleware(routing);
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: ['/', '/(ja|en|pt-BR|zh-CN|de)/:path*'],
|
matcher: ['/', '/(de|en|pt-BR|zh-CN|ja)/:path*'],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 = {
|
export type LocaleType = {
|
||||||
code: LocaleCodeType;
|
code: LocaleCodeType;
|
||||||
|
|||||||
Reference in New Issue
Block a user