f9b087157b
- 말레이시아 실적 탭 줄에 [한글|EN] 토글(쿠키 mperf_lang), 고른 적 없으면 브라우저·OS 첫 언어(Accept-Language) ko → 한글, 그 밖 → 영어(app/lang.py) - 영문이면 performance-en.js(사전·패턴·낱말 치환, 창·알림까지) — 한국 실적 화면은 그대로 - 말레이시아 실적 공휴일 = 말레이시아 공휴일(live/holidays.py, 화면 언어로) - 라이브 커머스·말레이시아 재고도 같은 기본 언어 규칙 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
270 lines
25 KiB
JavaScript
270 lines
25 KiB
JavaScript
/* 말레이시아 실적 영문 화면(2026-11-20) — 서버가 영문(lang=en)일 때만 performance.js 앞에 싣는다. 한국 실적은 안 쓴다.
|
||
*
|
||
* 같은 템플릿·performance.js 를 한국 실적과 함께 쓰므로 한글을 고치지 않고, 그린 뒤 글자를 바꾼다:
|
||
* ① 사전(EN — 한글 문구 그대로가 키) ② 패턴(RULES — 날짜·기간·이름이 섞인 글) ③ 낱말 치환(PHRASES — 결과에 한글이 안 남을 때만).
|
||
* .perf 안 글자·title·aria-label·placeholder, 나중에 생기는 창·메뉴·말풍선(MutationObserver), 알림·확인 창 문구(erpAlert·erpConfirm·alert·confirm).
|
||
* 못 바꾼 글은 한글 그대로 두고 window.__perfI18nMissing 에 모은다 — tests/js/perf_malaysia_en.browser.test.js 가 화면에 한글이 없는지 본다.
|
||
* 새 화면 문구를 넣으면 여기에도 영문을 넣는다. 긴 안내 문단(굵은 글자 섞임)은 템플릿에 {% if lang == 'en' %} 로 따로 쓴다.
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
const ROOT = document.querySelector(".perf[data-lang='en']");
|
||
if (!ROOT) return;
|
||
const HANGUL = /[가-힣]/;
|
||
|
||
const EN = {
|
||
// 탭·기간·표
|
||
"매출 실적": "Sales", "광고비": "Ad Spend", "실적 설정": "Settings", "수수료 설정": "Commission settings",
|
||
"말레이시아 실적 메뉴": "Malaysia Sales menu", "말레이시아 실적 설정": "Settings", "기간 선택": "Period", "이번달": "This month",
|
||
"올해": "This year", "직접선택": "Custom", "조회": "Apply", "전체": "All", "적용": "Apply", "표시 기준": "Show",
|
||
"총매출": "Gross sales", "수수료": "Commission", "수수료 차감 매출": "Net sales", "매출": "Sales",
|
||
"엑셀 업로드": "Excel upload", "파일 업로드": "File upload", "단위: RM": "Unit: RM", "광고비(ROAS%)": "Ad spend (ROAS%)",
|
||
"날짜": "Date", "월": "Month", "일 합계": "Daily total", "월 합계": "Monthly total", "기간 합계": "Period total",
|
||
"연간 합계": "Annual total", "주간합계": "Week total", "합계": "Total", "쇼핑몰": "Marketplace", "채널": "Channel",
|
||
"매출 비중": "Share", "비중": "Share", "그룹": "Group", "수동 입력": "Manual entry", "ROAS": "ROAS",
|
||
"일별 매출 추이": "Daily sales trend", "월별 매출 추이": "Monthly sales trend", "쇼핑몰별 비중": "Share by marketplace",
|
||
"일별 광고비 추이": "Daily ad spend trend", "월별 광고비 추이": "Monthly ad spend trend", "채널별 비중": "Share by channel",
|
||
"일자별 × 쇼핑몰": "Daily × marketplace", "월별 × 쇼핑몰": "Monthly × marketplace",
|
||
"일자별 × 광고 채널": "Daily × ad channel", "월별 × 광고 채널": "Monthly × ad channel",
|
||
"기간 내 매출이 없습니다.": "No sales in this period.", "기간 내 광고비가 없습니다.": "No ad spend in this period.",
|
||
"매출 없음": "No sales", "하위 쇼핑몰 접기/펴기": "Collapse / expand sub columns",
|
||
"수동 입력 쇼핑몰 매출을 엑셀 파일로 한 번에 입력": "Enter manual sales from an Excel file",
|
||
"매출에 포함된 쇼핑몰이 없습니다.": "No marketplaces are included in sales.", "에서 쇼핑몰 사용을 켜세요.": "— turn marketplaces on.",
|
||
"매출 아래 주황 숫자 = 그 쇼핑몰 광고비(ROAS%) — 광고비 탭과 같은 값. 쇼핑몰 그룹(합계) 칸 아래, ROAS = 쇼핑몰 + 라이브커머스 매출 ÷ 광고비":
|
||
"Orange figures = that marketplace's ad spend (ROAS%), same as the Ad Spend tab. Shown under the marketplace group (total) cell; ROAS = shop + live commerce sales ÷ ad spend",
|
||
"중지됨": "Stopped",
|
||
// 설정
|
||
"쇼핑몰 설정": "Marketplaces", "사용": "Active", "매출 집계": "In sales", "수수료율": "Commission rate",
|
||
"미설정": "Not set", "변경": "Change", "이름 변경": "Rename", "삭제": "Delete", "그룹 없음": "No group",
|
||
"직접 추가": "Custom", "+ 쇼핑몰 추가(수동 입력)": "+ Add marketplace (manual)", "+ 그룹 추가": "+ Add group",
|
||
"끌어서 순서 변경": "Drag to reorder", "끌어서 순서 변경(그룹은 하위 쇼핑몰과 함께 움직임)": "Drag to reorder (a group moves with its sub marketplaces)",
|
||
"사용 여부": "Active", "매출 집계에 포함": "Include in sales",
|
||
"⠿ 를 끌어 순서를 바꾸면 매출 실적 열 순서에 그대로 반영됩니다. 그룹은 직접 추가한 쇼핑몰만 묶을 수 있습니다.":
|
||
"Drag ⠿ to reorder — the sales table columns follow. Only custom marketplaces can be grouped.",
|
||
"실적 설정에서 직접 추가한 쇼핑몰": "Marketplace added in settings",
|
||
"수동 입력 전용 쇼핑몰 — API 연동이 없어 늘 켜져 있습니다": "Manual-only marketplace — always on (no API)",
|
||
"API 연동 없이 실적 일자별 표에 매출을 직접 입력하는 쇼핑몰을 추가": "Add a marketplace whose sales you enter by hand in the daily table",
|
||
"직접 추가한 쇼핑몰을 묶는 그룹 — 그룹 매출 = 하위 쇼핑몰 매출 합계": "A group of custom marketplaces — group sales = sum of its marketplaces",
|
||
"그룹 — 그룹으로 묶으면 매출 실적에서 그룹 열이 하위 쇼핑몰 매출 합계": "Group — the group column shows the sum of its marketplaces",
|
||
"보기 설정": "View settings", "표 열 너비": "Column width", "자동(글자 길이)": "Auto (fit text)", "수동 조절": "Manual",
|
||
"조절한 너비 초기화": "Reset widths", "초기화했습니다": "Reset",
|
||
"매출 실적·광고비 화면을 보는 방식입니다. 이 브라우저에만 적용되며 고르면 바로 저장됩니다.":
|
||
"How the Sales and Ad Spend screens look. Applies to this browser only and saves immediately.",
|
||
"열 너비가 글자 길이에 맞춰 자동으로 정해집니다.": "Column widths fit the text automatically.",
|
||
"매출 실적·광고비 표 머리글의 오른쪽 경계를 끌어 너비를 바꿉니다(두 번 누르면 그 열만 자동 너비). 바꾼 너비는 계속 유지됩니다.":
|
||
"Drag the right edge of a header to resize (double-click for auto width). Widths are kept.",
|
||
"매출 실적·광고비 표에서 조절한 열 너비를 모두 지우고 자동 너비로 되돌릴까요?": "Clear all adjusted column widths and go back to auto width?",
|
||
"공통 보기 설정": "Shared view settings", "모든 사용자의 매출 실적 화면에 적용됩니다. 고르면 바로 저장됩니다.":
|
||
"Applies to everyone's Sales screen. Saves immediately.",
|
||
"숨길 쇼핑몰": "Hidden columns",
|
||
"체크한 쇼핑몰은 일자별 표에서 열만 숨겨집니다. 일 합계·그래프·누적 금액은 그대로입니다.":
|
||
"Checked marketplaces are hidden from the daily table only. Totals, charts and cumulative amounts stay the same.",
|
||
"수수료율은": "Commission rates apply from the", "적용 시작일": "Effective date",
|
||
"부터 반영되고, 그 전 실적은 예전 요율로 계산됩니다(과거 실적이 바뀌지 않음).": "; earlier sales keep the old rate (past results don't change).",
|
||
"쇼핑몰별 수수료율을 설정합니다. 바로 저장되며 실적 화면의 수수료·수수료 차감 매출에 반영됩니다.":
|
||
"Set the commission rate per marketplace. Saved immediately and used for commission and net sales.",
|
||
// 창(performance.js)
|
||
"닫기": "Close", "업로드": "Upload", "취소": "Cancel", "저장": "Save", "확인": "OK", "샘플 파일 받기": "Download sample",
|
||
"수동 입력 엑셀 업로드": "Excel upload (manual sales)", "엑셀 파일": "Excel file", "엑셀 파일을 고르세요.": "Choose an Excel file.",
|
||
"올리는 중…": "Uploading…", "불러오는 중…": "Loading…", "없음": "None",
|
||
"1열에": "Column 1:", ", 2열부터": ", from column 2:", "쇼핑몰 이름": "marketplace names",
|
||
"을 머리글로 적고 그날": "as headers, then each day's", "을 넣습니다. 값이 있는 칸만 반영되고(같은 날 값은 덮어씀) 빈 칸은 기존 값 그대로입니다.":
|
||
". Only filled cells are saved (overwriting that day); empty cells stay as they are.",
|
||
"반영할 값이 없습니다(값이 있는 칸이 없음).": "Nothing to save (no filled cells).",
|
||
"창을 닫으면 표·합계·그래프가 다시 계산됩니다.": "Totals and charts are recalculated when you close this window.",
|
||
"메모 삽입": "Insert note", "메모 수정": "Edit note", "메모 삭제": "Delete note", "메모": "Note",
|
||
"메모를 입력하세요 (Ctrl+Enter 저장)": "Type a note (Ctrl+Enter to save)",
|
||
"수수료율(%)": "Commission rate (%)", "예: 5, 10.8, 15.35": "e.g. 5, 10.8, 15.35", "처음부터(과거 전체)": "From the start (all past)",
|
||
"이 날짜부터 새 요율로 계산하고, 그 전 실적은 예전 요율을 유지합니다.": "The new rate applies from this date; earlier sales keep the old rate.",
|
||
"변경 이력": "Change history", "요율": "Rate", "변경자": "Changed by", "처음부터": "From the start",
|
||
"이력이 없습니다(현재 0%).": "No history (currently 0%).",
|
||
"이 수수료 이력을 삭제할까요? 해당 기간 실적의 수수료가 다시 계산됩니다.": "Delete this rate? Commission for that period will be recalculated.",
|
||
"쇼핑몰 추가(수동 입력)": "Add marketplace (manual)", "그룹 추가": "Add group", "이름": "Name",
|
||
"그룹 이름 변경": "Rename group", "쇼핑몰 이름 변경": "Rename marketplace", "언어": "Language",
|
||
"숫자 또는 1000+2000 같은 계산식만 입력하세요.": "Enter a number or a formula such as 10.5+20.",
|
||
// 서버 오류(말레이시아 실적에서 날 수 있는 것)
|
||
"금액이 너무 큽니다.": "The amount is too large.", "날짜가 필요합니다.": "A date is required.",
|
||
"알 수 없는 쇼핑몰입니다.": "Unknown marketplace.", "알 수 없는 광고 채널입니다.": "Unknown ad channel.",
|
||
"이 쇼핑몰은 수동 입력을 쓰지 않습니다(실적 설정에서 켜세요).": "Manual entry is off for this marketplace (turn it on in Settings).",
|
||
"이름을 입력하세요.": "Enter a name.", "그룹은 다른 그룹에 넣을 수 없습니다.": "A group can't be put in another group.",
|
||
"그룹은 이름만 바꿀 수 있습니다.": "Only a group's name can be changed.", "그룹을 찾지 못했습니다.": "Group not found.",
|
||
"수동 입력 전용 쇼핑몰은 수동 입력을 끌 수 없습니다.": "Manual entry can't be turned off for a manual-only marketplace.",
|
||
"수수료 이력을 찾지 못했습니다.": "Rate history not found.", "수수료율은 0 ~ 100 사이여야 합니다.": "The rate must be between 0 and 100.",
|
||
"수수료율은 소수점 셋째 자리까지 입력할 수 있습니다.": "Up to 3 decimal places.",
|
||
"수수료율은 숫자로 입력하세요(예: 5, 10.8, 15.35).": "Enter the rate as a number (e.g. 5, 10.8, 15.35).",
|
||
"적용 시작일을 입력하세요.": "Enter the effective date.", "순서 목록이 비었습니다.": "The order list is empty.",
|
||
"순서 목록에 같은 쇼핑몰이 두 번 있습니다.": "A marketplace appears twice in the order.", "파일을 고르세요.": "Choose a file.",
|
||
"숫자와 + - * / ( ) 만 입력할 수 있습니다.": "Only numbers and + - * / ( ) are allowed.", "계산식이 끝나지 않았습니다.": "The formula is incomplete.",
|
||
"0으로 나눌 수 없습니다.": "Can't divide by 0.", "괄호가 맞지 않습니다.": "Brackets don't match.",
|
||
"계산식이 올바르지 않습니다.": "The formula is invalid.", "계산식이 너무 깁니다.": "The formula is too long.", "계산할 수 없는 식입니다.": "Can't calculate this formula.",
|
||
"빈 파일입니다.": "The file is empty.", "파일이 너무 큽니다(5MB 이하).": "The file is too large (5 MB max).",
|
||
"엑셀(.xlsx) 파일을 읽을 수 없습니다. 샘플 파일 양식으로 저장해 올려 주세요.": "Can't read the Excel (.xlsx) file. Save it in the sample format and upload again.",
|
||
"1행에 날짜와 쇼핑몰 이름 머리글이 없습니다.": "Row 1 needs Date and marketplace name headers.",
|
||
"기본 쇼핑몰은 삭제할 수 없습니다(사용을 끄세요).": "Built-in marketplaces can't be deleted (turn them off instead).",
|
||
"기본 쇼핑몰은 이름·그룹을 바꿀 수 없습니다.": "Built-in marketplaces can't be renamed or grouped.",
|
||
"요청 실패": "Request failed",
|
||
// 쇼핑몰 이름(seed — 바꾼 이름은 낱말 치환으로)
|
||
"틱톡": "TikTok", "쇼피": "Shopee", "라자다": "Lazada",
|
||
};
|
||
|
||
const MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||
const DOW = { "월": "Mon", "화": "Tue", "수": "Wed", "목": "Thu", "금": "Fri", "토": "Sat", "일": "Sun" };
|
||
const list = function (s) { return s.split(", ").map(tr).join(", "); };
|
||
// 값이 섞인 글 — [정규식, (일치) → 영문]. 위에서부터 처음 맞는 것.
|
||
const RULES = [
|
||
[/^(\d{4})년 (\d{1,2})월 (\d{1,2})일 ~ (?:(\d{4})년 )?(\d{1,2})월 (\d{1,2})일$/, function (m) {
|
||
return MON[m[2] - 1] + " " + m[3] + (m[4] && m[4] !== m[1] ? ", " + m[1] : "") + " – " + MON[m[5] - 1] + " " + m[6] + ", " + (m[4] || m[1]); }],
|
||
[/^(\d{4})년 (\d{1,2})월 (\d{1,2})일 \((.)\)$/, function (m) { return DOW[m[4]] + ", " + MON[m[2] - 1] + " " + m[3] + ", " + m[1]; }],
|
||
[/^(\d{4})년 (\d{1,2})월$/, function (m) { return MON[m[2] - 1] + " " + m[1]; }],
|
||
[/^(\d{4})년$/, function (m) { return m[1]; }],
|
||
[/^(\d{2}\/\d{2})\((.)\)$/, function (m) { return m[1] + " " + DOW[m[2]]; }],
|
||
[/^주간합계 \((.+)\)$/, function (m) { return "Week total (" + m[1] + ")"; }],
|
||
[/^(\d{4})년 누적$/, function (m) { return m[1] + " year to date"; }],
|
||
[/^(\d{4})년 누적 광고비$/, function (m) { return m[1] + " ad spend YTD"; }],
|
||
[/^(\d{4})년 (\d{1,2})월 쇼핑몰별 누적 실적$/, function (m) { return MON[m[2] - 1] + " " + m[1] + " by marketplace"; }],
|
||
[/^(\d{4})년 (\d{1,2})월 채널별 광고비$/, function (m) { return MON[m[2] - 1] + " " + m[1] + " ad spend by channel"; }],
|
||
[/^(.+) 대비$/, function (m) { return "vs " + tr(m[1]).toLowerCase(); }],
|
||
[/^(.+) 비교 없음$/, function (m) { return "no comparison with " + tr(m[1]).toLowerCase(); }],
|
||
[/^쇼핑몰: (\d+)곳$/, function (m) { return "Marketplaces: " + m[1]; }],
|
||
[/^쇼핑몰: 전체$/, function () { return "Marketplaces: All"; }],
|
||
[/^하위 쇼핑몰 (\d+)곳 — /, function (m) { return m[1] + " sub marketplaces — the group column on Sales = their sum (commission at each marketplace's rate)"; }],
|
||
[/^(.+) — 하위 쇼핑몰 (\d+)곳 매출 합계$/, function (m) { return tr(m[1]) + " — sum of " + m[2] + " sub marketplaces"; }],
|
||
[/^(.+) — 수동 입력\(날짜 칸을 눌러 입력\)$/, function (m) { return tr(m[1]) + " — manual entry (click a date cell)"; }],
|
||
[/^(.+) 하위 쇼핑몰 (접기|펴기)$/, function (m) { return (m[2] === "접기" ? "Collapse " : "Expand ") + tr(m[1]); }],
|
||
[/^(.+) 열 (접기|펴기)$/, function (m) { return (m[2] === "접기" ? "Collapse column " : "Expand column ") + tr(m[1]); }],
|
||
[/^(.+) — 날짜 칸을 눌러 광고비 입력\. 괄호 = ROAS\((.+) 매출 ÷ 광고비\)$/, function (m) {
|
||
return tr(m[1]) + " — click a date cell to enter ad spend. Brackets = ROAS (" + tr(m[2]) + " sales ÷ ad spend)"; }],
|
||
[/^총매출 RM (.+)$/, function (m) { return "Gross sales RM " + m[1]; }],
|
||
[/^(\d{1,2})월 (.+)$/, function (m) { return MON[m[1] - 1] + " " + m[2]; }], // 그래프 말풍선 "10월 1,834.55 RM"
|
||
[/^(\d{1,2})월$/, function (m) { return MON[m[1] - 1]; }],
|
||
[/^입력 가능한 쇼핑몰: (.*)$/, function (m) { return "Marketplaces you can enter: " + list(m[1]); }],
|
||
[/^건너뛴 열: (.*)$/, function (m) { return "Skipped columns: " + m[1].split(", ").map(function (c) {
|
||
return c.replace(/^(.*)\((알 수 없는 쇼핑몰|수동 입력 꺼짐)\)$/, function (_, n, why) {
|
||
return tr(n) + " (" + (why === "수동 입력 꺼짐" ? "manual entry off" : "unknown marketplace") + ")"; }); }).join(", "); }],
|
||
[/^(.+) · (\d{4}\.\d{2}\.\d{2}) 메모$/, function (m) { return "Note · " + tr(m[1]) + " · " + m[2]; }],
|
||
[/^(메모 삽입|메모 수정) · (.+) · (\d{4}\.\d{2}\.\d{2})$/, function (m) { return tr(m[1]) + " · " + tr(m[2]) + " · " + m[3]; }],
|
||
[/^(.+) 칸의 메모를 지울까요\?$/, function (m) { return "Delete the note in " + tr(m[1]) + "?"; }],
|
||
[/^(.+) 수수료율$/, function (m) { return tr(m[1]) + " commission rate"; }],
|
||
[/^쇼핑몰 \[(.+)\]을 삭제할까요\?(?: 입력해 둔 매출 ([\d,]+)일치와 수수료율도 함께 지워지며 되돌릴 수 없습니다\.)?$/, function (m) {
|
||
return "Delete marketplace [" + tr(m[1]) + "]?" + (m[2] ? " Its " + m[2] + " days of entered sales and commission rates will be deleted too. This can't be undone." : ""); }],
|
||
[/^그룹 \[(.+)\]을 삭제할까요\? 하위 쇼핑몰은 지워지지 않고 그룹 없음이 됩니다\.$/, function (m) {
|
||
return "Delete group [" + tr(m[1]) + "]? Its marketplaces stay, with no group."; }],
|
||
[/^([\d,]+)칸 반영 \((.+)\)$/, function (m) { return m[1] + " cells saved (" + m[2] + ")"; }],
|
||
[/^(.+) ([\d,]+)일$/, function (m) { return tr(m[1]) + " " + m[2] + " days"; }],
|
||
[/^저장 실패\((.+?)\): (.*)$/, function (m) { return "Save failed (" + m[1] + "): " + tr(m[2]); }],
|
||
[/^(저장|삭제|메모 저장|메모 삭제|순서 저장|업로드) 실패: (.*)$/, function (m) {
|
||
return { "저장": "Save", "삭제": "Delete", "메모 저장": "Saving the note", "메모 삭제": "Deleting the note", "순서 저장": "Saving the order", "업로드": "Upload" }[m[1]] + " failed: " + tr(m[2]); }],
|
||
[/^업로드 실패 \((\d+)\)$/, function (m) { return "Upload failed (" + m[1] + ")"; }],
|
||
[/^접은 열을 저장하지 못했습니다: (.*)$/, function (m) { return "Couldn't save folded columns: " + tr(m[1]); }],
|
||
[/^요청 실패 \((\d+)\)$/, function (m) { return "Request failed (" + m[1] + ")"; }],
|
||
[/^(.*) \(숫자 또는 1000\+2000 같은 계산식\)$/, function (m) { return tr(m[1]) + " (a number or a formula such as 10.5+20)"; }],
|
||
[/^같은 이름\((.+)\)이 이미 있습니다\.$/, function (m) { return "The name (" + m[1] + ") already exists."; }],
|
||
[/^이름은 (\d+)자까지입니다\.$/, function (m) { return "Names can be up to " + m[1] + " characters."; }],
|
||
[/^메모는 ([\d,]+)자까지 쓸 수 있습니다\.$/, function (m) { return "Notes can be up to " + m[1] + " characters."; }],
|
||
[/^잘못된 칸이 (\d+)개(\+?) 있어 아무것도 저장하지 않았습니다\. 고친 뒤 다시 올려 주세요\.$/, function (m) {
|
||
return m[1] + m[2] + " invalid cells — nothing was saved. Fix them and upload again."; }],
|
||
[/^([A-Z]+\d+): 금액이 숫자가 아닙니다\((.*)\)\.$/, function (m) { return m[1] + ": the amount is not a number (" + m[2] + ")."; }],
|
||
[/^([A-Z]+\d+): 금액이 너무 큽니다\.$/, function (m) { return m[1] + ": the amount is too large."; }],
|
||
[/^([A-Z]+\d+): 날짜를 읽을 수 없습니다\((.*)\)\.$/, function (m) { return m[1] + ": can't read the date (" + m[2] + ")."; }],
|
||
[/^(\d+)행: 날짜가 비어 있습니다\.$/, function (m) { return "Row " + m[1] + ": the date is empty."; }],
|
||
[/^([A-Z]+\d+): (.+) (\d{4}-\d{2}-\d{2}) 이 ([A-Z]+\d+) 와 겹칩니다\.$/, function (m) {
|
||
return m[1] + ": " + tr(m[2]) + " " + m[3] + " overlaps " + m[4] + "."; }],
|
||
[/^([A-Z]+\d+) (.+): 같은 쇼핑몰 열이 두 번 있습니다\.$/, function (m) { return m[1] + " " + tr(m[2]) + ": the same marketplace column appears twice."; }],
|
||
[/^반영할 쇼핑몰 열이 없습니다\./, function () { return "No columns to save — use the names of marketplaces with manual entry on as headers."; }],
|
||
[/^한 번에 ([\d,]+)일까지 올릴 수 있습니다\.$/, function (m) { return "Up to " + m[1] + " days per upload."; }],
|
||
[/^(.+) 형식이 올바르지 않습니다\(YYYY-MM-DD\)\.$/, function (m) { return tr(m[1]) + " must be YYYY-MM-DD."; }],
|
||
];
|
||
|
||
// 낱말 치환 — 긴 것부터. 결과에 한글이 하나도 안 남을 때만 쓴다(문장이 반쯤 바뀌지 않게).
|
||
const PHRASES = [
|
||
["라이브커머스", "Live Commerce"], ["쇼핑몰", "Shop"], ["틱톡", "TikTok"], ["쇼피", "Shopee"], ["라자다", "Lazada"],
|
||
["수수료 차감 매출", "net sales"], ["매출 대비 광고비", "ad spend to sales"], ["누적 광고비", "ad spend YTD"],
|
||
["전년 같은 기간", "same period last year"], ["전월 같은 기간", "same period last month"], ["전주 같은 기간", "same period last week"],
|
||
["전일 같은 기간", "same time yesterday"], ["직전 기간 같은 기간", "same span of the previous period"],
|
||
["같은 기간", "same period"], ["직전 기간", "previous period"],
|
||
["이번달", "This month"], ["이번주", "This week"], ["올해", "This year"], ["오늘", "Today"], ["선택 기간", "Selected period"],
|
||
["해당 월", "That month"], ["해당 주", "That week"], ["해당 연도", "That year"], ["해당일", "That day"],
|
||
["이전달", "Previous month"], ["다음달", "Next month"], ["이전주", "Previous week"], ["다음주", "Next week"],
|
||
["이전해", "Previous year"], ["다음해", "Next year"], ["다음날", "Next day"],
|
||
["전월", "last month"], ["전주", "last week"], ["전년", "last year"], ["전일", "previous day"],
|
||
["이전", "Previous"], ["다음", "Next"], ["광고비", "ad spend"], ["매출", "sales"], ["누적", "YTD"], ["대체", "(Replacement)"],
|
||
["날짜", "date"], ["시작일", "start date"], ["종료일", "end date"],
|
||
].sort(function (a, b) { return b[0].length - a[0].length; });
|
||
|
||
const missing = window.__perfI18nMissing = [];
|
||
const done = new Map();
|
||
function tr(text) {
|
||
if (!text || !HANGUL.test(text)) return text;
|
||
if (done.has(text)) return done.get(text);
|
||
const lead = text.match(/^\s*/)[0], tail = text.match(/\s*$/)[0], core = text.trim();
|
||
let out = EN[core];
|
||
if (out === undefined) {
|
||
for (let i = 0; i < RULES.length; i++) {
|
||
const m = core.match(RULES[i][0]);
|
||
if (m) { out = RULES[i][1](m); break; }
|
||
}
|
||
}
|
||
if ((out === undefined || HANGUL.test(out)) && core.indexOf("\n") >= 0) { // 여러 줄 알림 — 줄마다
|
||
const lines = core.split("\n").map(tr);
|
||
out = lines.some(function (l) { return HANGUL.test(l); }) ? undefined : lines.join("\n");
|
||
}
|
||
if (out === undefined || HANGUL.test(out)) {
|
||
let s = core;
|
||
PHRASES.forEach(function (p) { s = s.split(p[0]).join(p[1]); });
|
||
out = HANGUL.test(s) ? undefined : s.replace(/\s+/g, " ").replace(/^([a-z])/, function (c) { return c.toUpperCase(); });
|
||
}
|
||
if (out === undefined) { if (missing.indexOf(core) < 0) missing.push(core); }
|
||
const res = out === undefined ? text : lead + out + tail;
|
||
done.set(text, res);
|
||
return res;
|
||
}
|
||
|
||
const ATTRS = ["title", "aria-label", "placeholder"];
|
||
function noText(el) { return !el || !!el.closest("[translate='no'], script, style, textarea"); }
|
||
function fixAttrs(el) {
|
||
if (el.closest("[translate='no']")) return;
|
||
ATTRS.forEach(function (a) {
|
||
const v = el.getAttribute(a);
|
||
if (v && HANGUL.test(v)) { const t = tr(v); if (t !== v) el.setAttribute(a, t); }
|
||
});
|
||
}
|
||
function fixText(n) {
|
||
if (HANGUL.test(n.nodeValue) && !noText(n.parentElement)) { const v = tr(n.nodeValue); if (v !== n.nodeValue) n.nodeValue = v; }
|
||
}
|
||
function walk(root) {
|
||
if (!root) return;
|
||
if (root.nodeType === 3) { fixText(root); return; }
|
||
if (root.nodeType !== 1) return;
|
||
fixAttrs(root);
|
||
const tw = document.createTreeWalker(root, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
|
||
for (let n = tw.nextNode(); n; n = tw.nextNode()) {
|
||
if (n.nodeType === 3) fixText(n); else fixAttrs(n);
|
||
}
|
||
}
|
||
|
||
// 알림·확인 창 문구 — 창을 그리기 전에 바꾼다(erp-dialog.js 창의 [확인]·[취소] 단추는 아래 관찰자가 바꾼다).
|
||
["erpAlert", "erpConfirm", "erpPrompt"].forEach(function (name) {
|
||
const orig = window[name];
|
||
if (typeof orig === "function") window[name] = function (msg) { const a = Array.prototype.slice.call(arguments); a[0] = tr(String(msg)); return orig.apply(this, a); };
|
||
});
|
||
["alert", "confirm"].forEach(function (name) {
|
||
const orig = window[name];
|
||
window[name] = function (msg) { return orig.call(window, tr(String(msg == null ? "" : msg))); };
|
||
});
|
||
|
||
// 이 화면 것만 — .perf 안 + 실적 창·메뉴·말풍선(perf-…)·알림 창. ERP 셸(사이드바·공지 등)은 건드리지 않는다.
|
||
function mine(node) {
|
||
const el = node.nodeType === 1 ? node : node.parentElement;
|
||
return !!el && (ROOT.contains(el) || !!el.closest('[class*="perf-"], .erp-dialog-backdrop'));
|
||
}
|
||
walk(ROOT);
|
||
ROOT.classList.add("is-i18n");
|
||
new MutationObserver(function (records) {
|
||
records.forEach(function (r) {
|
||
if (r.type !== "childList") { if (mine(r.target)) walk(r.target); return; }
|
||
r.addedNodes.forEach(function (n) { if (mine(n)) walk(n); });
|
||
});
|
||
}).observe(document.body, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ATTRS });
|
||
window.__perfI18n = tr;
|
||
})();
|