fix(gateway): use Korean server labels by default
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
|||||||
import type { GatewayApiContext } from './context.js';
|
import type { GatewayApiContext } from './context.js';
|
||||||
import { resolveLocalAccountProfilePolicy } from './auth/localAccountPolicy.js';
|
import { resolveLocalAccountProfilePolicy } from './auth/localAccountPolicy.js';
|
||||||
import { GATEWAY_BUILD_STATUSES, GATEWAY_PROFILE_STATUSES } from './orchestrator/profileRepository.js';
|
import { GATEWAY_BUILD_STATUSES, GATEWAY_PROFILE_STATUSES } from './orchestrator/profileRepository.js';
|
||||||
import { orderGatewayProfiles } from './profileOrder.js';
|
import { orderGatewayProfiles, resolveGatewayProfileKoreanName } from './profileOrder.js';
|
||||||
import { purifyGatewayNoticeHtml } from './security/gatewayNoticeHtml.js';
|
import { purifyGatewayNoticeHtml } from './security/gatewayNoticeHtml.js';
|
||||||
|
|
||||||
const zProfileStatus = z.enum(GATEWAY_PROFILE_STATUSES);
|
const zProfileStatus = z.enum(GATEWAY_PROFILE_STATUSES);
|
||||||
@@ -1585,7 +1585,7 @@ export const adminRouter = router({
|
|||||||
instanceKey: profile.instanceKey,
|
instanceKey: profile.instanceKey,
|
||||||
currentScenario: profile.currentScenario,
|
currentScenario: profile.currentScenario,
|
||||||
meta: {
|
meta: {
|
||||||
...(typeof profile.meta.korName === 'string' ? { korName: profile.meta.korName } : {}),
|
korName: resolveGatewayProfileKoreanName(profile.profile, profile.meta.korName),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type {
|
|||||||
GatewayProfileRepository,
|
GatewayProfileRepository,
|
||||||
GatewayProfileStatus,
|
GatewayProfileStatus,
|
||||||
} from '../orchestrator/profileRepository.js';
|
} from '../orchestrator/profileRepository.js';
|
||||||
import { orderGatewayProfiles } from '../profileOrder.js';
|
import { orderGatewayProfiles, resolveGatewayProfileKoreanName } from '../profileOrder.js';
|
||||||
|
|
||||||
export type LobbyMapSnapshot = {
|
export type LobbyMapSnapshot = {
|
||||||
updatedAt: string | null;
|
updatedAt: string | null;
|
||||||
@@ -102,7 +102,7 @@ export class RepositoryProfileStatusService implements GatewayProfileStatusServi
|
|||||||
battleSimRunning: false,
|
battleSimRunning: false,
|
||||||
tournamentRunning: false,
|
tournamentRunning: false,
|
||||||
},
|
},
|
||||||
korName: (meta.korName as string | undefined) ?? row.profile,
|
korName: resolveGatewayProfileKoreanName(row.profile, meta.korName),
|
||||||
color: (meta.color as string | undefined) ?? '#ffffff',
|
color: (meta.color as string | undefined) ?? '#ffffff',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,24 @@
|
|||||||
export const GATEWAY_PROFILE_ORDER = ['che', 'kwe', 'pwe', 'twe', 'nya', 'pya', 'hwe'] as const;
|
export const GATEWAY_PROFILE_ORDER = ['che', 'kwe', 'pwe', 'twe', 'nya', 'pya', 'hwe'] as const;
|
||||||
|
|
||||||
|
export const GATEWAY_PROFILE_KOREAN_NAMES = {
|
||||||
|
che: '체',
|
||||||
|
kwe: '퀘',
|
||||||
|
pwe: '풰',
|
||||||
|
twe: '퉤',
|
||||||
|
nya: '냐',
|
||||||
|
pya: '퍄',
|
||||||
|
hwe: '훼',
|
||||||
|
} as const satisfies Record<(typeof GATEWAY_PROFILE_ORDER)[number], string>;
|
||||||
|
|
||||||
const gatewayProfileOrder = new Map<string, number>(GATEWAY_PROFILE_ORDER.map((profile, index) => [profile, index]));
|
const gatewayProfileOrder = new Map<string, number>(GATEWAY_PROFILE_ORDER.map((profile, index) => [profile, index]));
|
||||||
|
const gatewayProfileKoreanNames = new Map<string, string>(Object.entries(GATEWAY_PROFILE_KOREAN_NAMES));
|
||||||
|
|
||||||
|
export const resolveGatewayProfileKoreanName = (profile: string, configuredName?: unknown): string => {
|
||||||
|
if (typeof configuredName === 'string' && configuredName.trim()) {
|
||||||
|
return configuredName.trim();
|
||||||
|
}
|
||||||
|
return gatewayProfileKoreanNames.get(profile) ?? profile;
|
||||||
|
};
|
||||||
|
|
||||||
export const compareGatewayProfiles = (
|
export const compareGatewayProfiles = (
|
||||||
left: { profile: string; instanceKey: string },
|
left: { profile: string; instanceKey: string },
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ describe('admin profile navigation API', () => {
|
|||||||
profile: 'che',
|
profile: 'che',
|
||||||
instanceKey: '2',
|
instanceKey: '2',
|
||||||
currentScenario: '2',
|
currentScenario: '2',
|
||||||
meta: {},
|
meta: { korName: '체' },
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
expect(harness.getRuntimeStateListCount()).toBe(0);
|
expect(harness.getRuntimeStateListCount()).toBe(0);
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
import { GATEWAY_PROFILE_ORDER, orderGatewayProfiles } from '../src/profileOrder.js';
|
import {
|
||||||
|
GATEWAY_PROFILE_KOREAN_NAMES,
|
||||||
|
GATEWAY_PROFILE_ORDER,
|
||||||
|
orderGatewayProfiles,
|
||||||
|
resolveGatewayProfileKoreanName,
|
||||||
|
} from '../src/profileOrder.js';
|
||||||
|
|
||||||
describe('orderGatewayProfiles', () => {
|
describe('orderGatewayProfiles', () => {
|
||||||
it('uses the public server order instead of alphabetical profile order', () => {
|
it('uses the public server order instead of alphabetical profile order', () => {
|
||||||
@@ -29,3 +34,25 @@ describe('orderGatewayProfiles', () => {
|
|||||||
expect(profiles[0]?.profile).toBe('zeta');
|
expect(profiles[0]?.profile).toBe('zeta');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('resolveGatewayProfileKoreanName', () => {
|
||||||
|
it('uses the canonical Korean labels for every public profile', () => {
|
||||||
|
expect(GATEWAY_PROFILE_ORDER.map((profile) => resolveGatewayProfileKoreanName(profile))).toEqual(
|
||||||
|
GATEWAY_PROFILE_ORDER.map((profile) => GATEWAY_PROFILE_KOREAN_NAMES[profile])
|
||||||
|
);
|
||||||
|
expect(GATEWAY_PROFILE_ORDER.map((profile) => `${resolveGatewayProfileKoreanName(profile)}섭`)).toEqual([
|
||||||
|
'체섭',
|
||||||
|
'퀘섭',
|
||||||
|
'풰섭',
|
||||||
|
'퉤섭',
|
||||||
|
'냐섭',
|
||||||
|
'퍄섭',
|
||||||
|
'훼섭',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('preserves configured and unknown profile names', () => {
|
||||||
|
expect(resolveGatewayProfileKoreanName('che', ' 천하서버 ')).toBe('천하서버');
|
||||||
|
expect(resolveGatewayProfileKoreanName('custom')).toBe('custom');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user