mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 06:18:55 +00:00
refactor(accounts): localize codex identity labels
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import i18n from './i18n';
|
||||||
|
|
||||||
const FREE_PLAN_PARTS = new Set(['free']);
|
const FREE_PLAN_PARTS = new Set(['free']);
|
||||||
const PERSONAL_PLAN_PARTS = new Set(['plus', 'pro']);
|
const PERSONAL_PLAN_PARTS = new Set(['plus', 'pro']);
|
||||||
const BUSINESS_PLAN_PARTS = new Set(['team']);
|
const BUSINESS_PLAN_PARTS = new Set(['team']);
|
||||||
@@ -38,13 +40,13 @@ export function formatAccountVariantPart(part: string): string {
|
|||||||
|
|
||||||
switch (normalized) {
|
switch (normalized) {
|
||||||
case 'team':
|
case 'team':
|
||||||
return 'Team'; // TODO i18n: missing key for account variant team
|
return i18n.t('accountIdentity.team');
|
||||||
case 'free':
|
case 'free':
|
||||||
return 'Free'; // TODO i18n: missing key for account variant free
|
return i18n.t('accountIdentity.free');
|
||||||
case 'plus':
|
case 'plus':
|
||||||
return 'Plus'; // TODO i18n: missing key for account variant plus
|
return i18n.t('accountIdentity.plus');
|
||||||
case 'pro':
|
case 'pro':
|
||||||
return 'Pro'; // TODO i18n: missing key for account variant pro
|
return i18n.t('accountIdentity.pro');
|
||||||
default:
|
default:
|
||||||
return /^[a-f0-9]{8}$/i.test(normalized)
|
return /^[a-f0-9]{8}$/i.test(normalized)
|
||||||
? normalized
|
? normalized
|
||||||
@@ -104,7 +106,7 @@ function formatWorkspaceLabel(parts: string[]): {
|
|||||||
const workspaceId = parts.find((part) => /^[a-f0-9]{8}$/i.test(part));
|
const workspaceId = parts.find((part) => /^[a-f0-9]{8}$/i.test(part));
|
||||||
if (workspaceId) {
|
if (workspaceId) {
|
||||||
return {
|
return {
|
||||||
detailLabel: `Workspace ${workspaceId.toLowerCase()}`, // TODO i18n: missing key for workspace label
|
detailLabel: i18n.t('accountIdentity.workspace', { id: workspaceId.toLowerCase() }),
|
||||||
compactDetailLabel: workspaceId.toLowerCase(),
|
compactDetailLabel: workspaceId.toLowerCase(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -166,11 +168,13 @@ export function getAccountIdentityPresentation(
|
|||||||
const suffix = parts[parts.length - 1]?.toLowerCase();
|
const suffix = parts[parts.length - 1]?.toLowerCase();
|
||||||
if (suffix && BUSINESS_PLAN_PARTS.has(suffix)) {
|
if (suffix && BUSINESS_PLAN_PARTS.has(suffix)) {
|
||||||
const workspace = formatWorkspaceLabel(parts.slice(0, -1));
|
const workspace = formatWorkspaceLabel(parts.slice(0, -1));
|
||||||
const inlineLabel = ['Business', workspace.detailLabel].filter(Boolean).join(' · '); // TODO i18n: missing keys for Business/Personal audience labels
|
const inlineLabel = [i18n.t('accountIdentity.business'), workspace.detailLabel]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ');
|
||||||
return {
|
return {
|
||||||
email: resolvedEmail,
|
email: resolvedEmail,
|
||||||
audience: 'business',
|
audience: 'business',
|
||||||
audienceLabel: 'Business',
|
audienceLabel: i18n.t('accountIdentity.business'),
|
||||||
detailLabel: workspace.detailLabel,
|
detailLabel: workspace.detailLabel,
|
||||||
compactDetailLabel: workspace.compactDetailLabel,
|
compactDetailLabel: workspace.compactDetailLabel,
|
||||||
inlineLabel,
|
inlineLabel,
|
||||||
@@ -179,11 +183,11 @@ export function getAccountIdentityPresentation(
|
|||||||
|
|
||||||
if (suffix && FREE_PLAN_PARTS.has(suffix)) {
|
if (suffix && FREE_PLAN_PARTS.has(suffix)) {
|
||||||
const detailLabel = formatAudienceDetail(parts.slice(0, -1));
|
const detailLabel = formatAudienceDetail(parts.slice(0, -1));
|
||||||
const inlineLabel = ['Free', detailLabel].filter(Boolean).join(' · '); // TODO i18n: missing key for Free
|
const inlineLabel = [i18n.t('accountIdentity.free'), detailLabel].filter(Boolean).join(' · ');
|
||||||
return {
|
return {
|
||||||
email: resolvedEmail,
|
email: resolvedEmail,
|
||||||
audience: 'free',
|
audience: 'free',
|
||||||
audienceLabel: 'Free',
|
audienceLabel: i18n.t('accountIdentity.free'),
|
||||||
detailLabel,
|
detailLabel,
|
||||||
compactDetailLabel: detailLabel,
|
compactDetailLabel: detailLabel,
|
||||||
inlineLabel,
|
inlineLabel,
|
||||||
@@ -194,11 +198,13 @@ export function getAccountIdentityPresentation(
|
|||||||
const detailLabel = [formatAccountVariantPart(suffix), formatAudienceDetail(parts.slice(0, -1))]
|
const detailLabel = [formatAccountVariantPart(suffix), formatAudienceDetail(parts.slice(0, -1))]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' · ');
|
.join(' · ');
|
||||||
const inlineLabel = ['Personal', detailLabel].filter(Boolean).join(' · '); // TODO i18n: missing key for Personal
|
const inlineLabel = [i18n.t('accountIdentity.personal'), detailLabel]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ');
|
||||||
return {
|
return {
|
||||||
email: resolvedEmail,
|
email: resolvedEmail,
|
||||||
audience: 'personal',
|
audience: 'personal',
|
||||||
audienceLabel: 'Personal',
|
audienceLabel: i18n.t('accountIdentity.personal'),
|
||||||
detailLabel: detailLabel || formatAccountVariantPart(suffix),
|
detailLabel: detailLabel || formatAccountVariantPart(suffix),
|
||||||
compactDetailLabel: detailLabel || formatAccountVariantPart(suffix),
|
compactDetailLabel: detailLabel || formatAccountVariantPart(suffix),
|
||||||
inlineLabel,
|
inlineLabel,
|
||||||
@@ -228,17 +234,20 @@ export function getCodexIdentityBadge(
|
|||||||
presentation: Pick<AccountIdentityPresentation, 'audience' | 'detailLabel' | 'compactDetailLabel'>
|
presentation: Pick<AccountIdentityPresentation, 'audience' | 'detailLabel' | 'compactDetailLabel'>
|
||||||
): CodexIdentityBadge {
|
): CodexIdentityBadge {
|
||||||
if (presentation.audience === 'business') {
|
if (presentation.audience === 'business') {
|
||||||
return { audience: 'business', label: 'Business' };
|
return { audience: 'business', label: i18n.t('accountIdentity.business') };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presentation.audience === 'free') {
|
if (presentation.audience === 'free') {
|
||||||
return { audience: 'free', label: 'Free' };
|
return { audience: 'free', label: i18n.t('accountIdentity.free') };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presentation.audience === 'personal') {
|
if (presentation.audience === 'personal') {
|
||||||
return {
|
return {
|
||||||
audience: 'personal',
|
audience: 'personal',
|
||||||
label: presentation.compactDetailLabel ?? presentation.detailLabel ?? 'Personal',
|
label:
|
||||||
|
presentation.compactDetailLabel ??
|
||||||
|
presentation.detailLabel ??
|
||||||
|
i18n.t('accountIdentity.personal'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1705,6 +1705,15 @@ const resources = {
|
|||||||
personal: 'Pers',
|
personal: 'Pers',
|
||||||
variant: 'Variant',
|
variant: 'Variant',
|
||||||
},
|
},
|
||||||
|
accountIdentity: {
|
||||||
|
business: 'Business',
|
||||||
|
personal: 'Personal',
|
||||||
|
free: 'Free',
|
||||||
|
team: 'Team',
|
||||||
|
plus: 'Plus',
|
||||||
|
pro: 'Pro',
|
||||||
|
workspace: 'Workspace {{id}}',
|
||||||
|
},
|
||||||
accountCardStats: {
|
accountCardStats: {
|
||||||
notUsedYet: 'Not used yet',
|
notUsedYet: 'Not used yet',
|
||||||
},
|
},
|
||||||
@@ -4054,6 +4063,15 @@ const resources = {
|
|||||||
personal: '个人',
|
personal: '个人',
|
||||||
variant: '变体',
|
variant: '变体',
|
||||||
},
|
},
|
||||||
|
accountIdentity: {
|
||||||
|
business: '企业',
|
||||||
|
personal: '个人',
|
||||||
|
free: '免费',
|
||||||
|
team: '团队',
|
||||||
|
plus: 'Plus',
|
||||||
|
pro: 'Pro',
|
||||||
|
workspace: '工作区 {{id}}',
|
||||||
|
},
|
||||||
accountCardStats: {
|
accountCardStats: {
|
||||||
notUsedYet: '尚未使用',
|
notUsedYet: '尚未使用',
|
||||||
},
|
},
|
||||||
@@ -6475,6 +6493,15 @@ const resources = {
|
|||||||
personal: 'Cá nhân',
|
personal: 'Cá nhân',
|
||||||
variant: 'Biến thể',
|
variant: 'Biến thể',
|
||||||
},
|
},
|
||||||
|
accountIdentity: {
|
||||||
|
business: 'Doanh nghiệp',
|
||||||
|
personal: 'Cá nhân',
|
||||||
|
free: 'Miễn phí',
|
||||||
|
team: 'Nhóm',
|
||||||
|
plus: 'Plus',
|
||||||
|
pro: 'Pro',
|
||||||
|
workspace: 'Không gian {{id}}',
|
||||||
|
},
|
||||||
accountCardStats: {
|
accountCardStats: {
|
||||||
notUsedYet: 'Chưa sử dụng',
|
notUsedYet: 'Chưa sử dụng',
|
||||||
},
|
},
|
||||||
@@ -8678,6 +8705,15 @@ const resources = {
|
|||||||
personal: '個人',
|
personal: '個人',
|
||||||
variant: 'バリアント',
|
variant: 'バリアント',
|
||||||
},
|
},
|
||||||
|
accountIdentity: {
|
||||||
|
business: 'ビジネス',
|
||||||
|
personal: '個人',
|
||||||
|
free: '無料',
|
||||||
|
team: 'チーム',
|
||||||
|
plus: 'Plus',
|
||||||
|
pro: 'Pro',
|
||||||
|
workspace: 'ワークスペース {{id}}',
|
||||||
|
},
|
||||||
aiProvidersEntryCard: {
|
aiProvidersEntryCard: {
|
||||||
apiKeys: 'API Keys',
|
apiKeys: 'API Keys',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user