o2o-infinith-demo/supporters/src/lib/i18n.ts
Haewon Kam 0a0f64c29e merge: feature/ai-sentiment-rubric 진행분 (주변 안내 정본 반영, §8 인사이트) 반영
supporters/ 정본에 주변 안내(/stay·/en/stay)가 i18n 방식으로 들어왔다.
recoveryNotes 는 뷰 실데이터를 유지한다.
핸드오버 제목 날짜를 2026-09-12(토)로 맞추고, §8-1 과 §8-11 에 이번 통합에서
같은 사고를 되풀이한 기록과 재발 방지(머지 직전 브랜치 끝 재확인)를 남겼다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 15:20:46 +09:00

50 lines
3.6 KiB
TypeScript

// 사이트 공통(헤더·푸터·배너) 문자열과 언어 전환 규칙. 페이지 본문은 각 페이지가 맡고, 이 모듈은 Base.astro 가 쓴다.
// 언어 전환은 전역 하나(헤더)로만 한다. 페이지마다 따로 토글을 두지 않는다 (haewon 결정, 2026-09-10).
export type Lang = 'ko' | 'en';
/** 한국어 경로 ↔ 영어 경로. 영어판이 없는 한국어 페이지는 영어 홈으로, 반대는 한국어 홈으로 보낸다. */
const PAIRS: [string, string][] = [
['/', '/en'],
['/plan', '/en/plan'],
['/stay', '/en/stay'],
];
export function switchHref(pathname: string, to: Lang): string {
const p = pathname.replace(/\/index\.html$/, '/').replace(/\.html$/, '').replace(/\/$/, '') || '/';
for (const [ko, en] of PAIRS) {
if (to === 'en' && p === ko) return en;
if (to === 'ko' && p === en) return ko;
}
return to === 'en' ? '/en' : '/';
}
export const isEnPath = (pathname: string): boolean => /^\/en(\/|\.html$|$)/.test(pathname);
export const UI: Record<Lang, Record<string, string>> = {
ko: {
sample: '샘플 사이트입니다. 정식 공개 전입니다.',
brand: '서포터즈',
nav_posts: '상담 전 질문', nav_videos: '의료진 영상', nav_news: '뉴스룸', nav_stay: '주변 안내', nav_visit: '방문 안내', nav_plan: '회복 일정', nav_about: '매체 소개',
cta: '상담 예약',
back: '이전 페이지', backAria: '이전 페이지로 돌아가기', totop: '맨 위로',
switchLabel: 'EN', switchAria: 'Switch to English',
foot_sponsor: '이 매체는 {clinic}의 지원을 받아 서포터즈가 운영합니다. 글의 의학적 내용은 {clinic} 담당 원장의 검토를 거쳐 표시하며, 검토 전 글은 "의학 검토 대기"로 표시합니다. 편집 책임 {editor}.',
foot_clinic: '병원 정보', foot_visit: '방문 안내', foot_plan: '회복 일정', foot_about: '이 사이트에 대해', foot_corrections: '정정 기록', foot_request: '정정 요청', foot_editorial: '편집 기준 (운영자용)',
foot_phone: '전화', foot_fax: '팩스', foot_rep: '대표', foot_biz: '사업자등록번호',
foot_site: '공식 홈페이지', foot_youtube: '유튜브', foot_gu: '강남언니',
},
en: {
sample: 'Sample site. Not yet public.',
brand: 'Supporters',
nav_home: 'Home', nav_stay: 'Nearby', nav_plan: 'Recovery Planner', nav_visit: 'Getting Here', nav_clinic: 'Clinic Facts', nav_korean: '한국어 전체 보기',
cta: 'Book a consultation',
back: 'Back', backAria: 'Go back to the previous page', totop: 'Back to top',
switchLabel: 'KO', switchAria: '한국어로 보기',
// 아래 영문 foot_sponsor · foot_side 는 병원이 확정한 문구가 아니라 푸터 고지에 쓰지 않는다.
// 고지는 Base.astro 가 site.json 의 sponsorNoticeEn · factSheet 의 sideEffectNoticeEn 에서 읽고, 없으면 한국어 원문에 확인 대기 표기를 붙인다.
foot_sponsor: 'This site is run by supporters with support from {clinic}. Medical content is reviewed by the clinic\'s attending surgeon before it is marked as reviewed. Editor in charge: {editor}.',
foot_side: 'After surgery, side effects such as inflammation, bleeding or nerve damage may occur depending on the individual.',
foot_clinic: 'Clinic facts', foot_visit: 'Getting here', foot_plan: 'Recovery planner', foot_about: 'About this site (Korean)', foot_corrections: 'Corrections (Korean)', foot_request: 'Request a correction', foot_editorial: '',
foot_phone: 'Tel', foot_fax: 'Fax', foot_rep: 'Representative', foot_biz: 'Business no.',
foot_site: 'Official website (English)', foot_youtube: 'YouTube', foot_gu: 'Gangnam Unni',
},
};