Repository navigation
Expand file tree
/
Copy pathi18n.js
More file actions
601 lines (533 loc) · 18.4 KB
/
Copy pathi18n.js
File metadata and controls
601 lines (533 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
// i18n.js - Internationalization module for Lingomon
// Supports English (en) and Korean (ko) languages
const translations = {
en: {
// Context Menu
contextMenu: "Catch '%s'",
// Main UI
wordDex: "WordDex",
darkMode: "Dark",
lightMode: "Light",
languageEN: "EN",
languageKO: "KO",
// Search & Controls
searchPlaceholder: "Search words...",
sortAlpha: "A-Z",
sortRecent: "Recent",
sortRarity: "Rarity",
sortTag: "Tags",
// Filter Menu
filterMenuTitle: "Tags & Filters",
sortView: "Sort View",
sortByTags: "Sort by Tags",
sortByRarityAll: "Sort by Rarity (Show All)",
filterByTag: "Filter by Tag",
clearFilter: "Clear Filter",
quiz: "Quiz",
// Stats
collectionStats: "Collection Stats",
totalWords: "Total Words",
streak: "Streak",
longest: "Longest",
day: "day",
days: "days",
// Rarities
common: "common",
uncommon: "uncommon",
rare: "rare",
epic: "epic",
legendary: "legendary",
mythic: "mythic",
god: "GOD",
// Rarity Labels (for display)
COMMON: "COMMON",
UNCOMMON: "UNCOMMON",
RARE: "RARE",
EPIC: "EPIC",
LEGENDARY: "LEGENDARY",
MYTHIC: "MYTHIC",
GOD: "GOD",
// Messages
noWordsMessage: "No words collected yet. Right-click words on web pages to start collecting!",
noSearchResults: "No words found matching your search.",
deleteConfirm: "Delete \"{word}\" from your collection?",
deleteButton: "delete",
infoButton: "info",
// Charts
wordsCaughtLast7Days: "Words Caught (Last 7 Days)",
rarityDistribution: "Rarity Distribution",
// Badges
achievements: "Achievements",
hiddenBadges: "Hidden Badges",
maxLevel: "Max level!",
nextBadge: "Next:",
// Badge Names
firstDay: "First Day",
"7DayStreak": "7 Day Streak",
"10DayStreak": "10 Day Streak",
"30DayStreak": "30 Day Streak",
"100DayStreak": "100 Day Streak",
"365DayStreak": "365 Day Streak",
firstWord: "First Word",
"5Words": "5 Words",
"10Words": "10 Words",
"50Words": "50 Words",
"100Words": "100 Words",
"500Words": "500 Words",
firstSite: "First Site",
"5Sites": "5 Sites",
"10Sites": "10 Sites",
"50Sites": "50 Sites",
"100Sites": "100 Sites",
"500Sites": "500 Sites",
firstMythic: "First Mythic!",
meta: "Meta",
huh: "Huh???",
limbusCompany: "Limbus Company",
commonKiller: "Common Killer",
uncommonKiller: "Uncommon Killer",
rareKiller: "Rare Killer",
epicKiller: "Epic Killer",
legendaryKiller: "Legendary Killer",
mythicKiller: "Mythic Killer",
// Quiz Mode
quizStart: "Start Quiz",
quizQuestion: "Question",
quizOf: "of",
quizDefinition: "Definition:",
quizFillBlank: "Fill in the blank:",
quizTheWordIs: "The word is:",
quizSubmit: "Submit",
quizSkip: "Skip",
quizBack: "Back to WordDex",
quizTryAgain: "Try Again",
quizCorrect: "Correct! The word is \"{word}\".",
quizIncorrect: "Incorrect. The correct answer is \"{word}\".",
quizComplete: "Quiz Complete!",
quizScore: "Your Score:",
quizPerfect: "Perfect! You know your words!",
quizGreat: "Great job! You know most of your words!",
quizGood: "Good effort! Keep learning!",
quizPractice: "Keep practicing! Review your words more often.",
quizMinWords: "You need at least 3 words in your collection to start a quiz. Catch more words!",
quizAnswerPlaceholder: "Type your answer...",
// Quiz Menu
quizMenuTitle: "Quiz Settings",
quizNumQuestions: "Number of Questions",
quizStartBtn: "Start Quiz",
// Error Messages
wordNotFound: "Word not found in dictionary",
apiError: "API error",
timeout: "Request timeout. Please try again.",
invalidWord: "Invalid word format.",
tooShort: "Word must be at least 3 letters long.",
onlyLetters: "Word must contain only letters (no numbers or special characters).",
couldNotFetch: "Could not fetch definition.",
apiKeyError: "Unregistered Authentication Key",
systemError: "System Error",
requestError: "Incorrect Request",
dailyLimitExcess: "Daily API limit exceeded. Please try again tomorrow.",
// Frequency Info
frequency: "Frequency",
perMillion: "per million",
frequencyNA: "N/A (legacy word)",
sourceAPI: "API",
sourceLocalDB: "Local DB",
sourceKoreanAPI: "Korean API",
// Animation Messages
gotIt: "Got it",
tryAgain: "Try Again",
newWordCaught: "New Word Caught!",
alreadyCaught: "Already Caught! Definition Updated",
firstCaughtOn: "First caught:",
failedToCatch: "Failed to Catch",
// New Features (Profile, Tabs, Battle)
tabDex: "WordDex",
tabQuiz: "Quiz",
tabBattle: "Battle",
tabProfile: "Profile",
// Word Types (Short)
type_n: "n",
type_v: "v",
type_adj: "adj",
type_adv: "adv",
type_p: "p",
type_pre: "pre",
type_conj: "conj",
type_interj: "interj",
// Profile & Friends
profileOverview: "Overview",
profileFriends: "Friends",
friendRequests: "Friend Requests",
friendPending: "Pending Sent",
friendWaiting: "Waiting...",
friendAdd: "Add",
friendPlaceholder: "Enter username...",
battleChallenge: "Battle",
friendNotFound: "User not found",
friendSelf: "You cannot add yourself!",
friendExists: "Friend request already exists or you are already friends.",
requestSent: "Request sent!",
requestError: "Error sending request",
// Customization
editProfile: "Edit Profile",
custTitle: "Title",
custAvatar: "Avatar",
// Profile (Missing from previous block)
profileRating: "Rating",
profileWins: "W",
profileLosses: "L",
profileWords: "Words Collected",
profileTeam: "Defense Team",
profileSave: "Save Team",
profileBack: "Back to Dex",
profileLoginReq: "You must be logged in to battle!",
profileTeamReq: "Set up your team in Profile first!",
profileSaving: "Saving...",
profileSaved: "Saved!",
profileSaveFail: "Save Failed",
profileLoading: "Loading...",
profileError: "Error loading profile.",
forceBackup: "Force Backup",
// Battle
battleStart: "Battle Start!",
battleRun: "Run Away",
battleVS: "VS Opponent",
battleVictory: "Victory!",
battleDefeat: "Defeat...",
battleFainted: "{word} fainted!",
battleAttacks: "{attacker} attacks! {damage} damage!",
battleBack: "Back to Menu",
battleArena: "Battle Arena",
battleRandom: "Random Battle",
battleFriendId: "Trainer ID / Name",
battleGo: "Go",
battleCancel: "Cancel",
battleSearching: "Searching for opponent...",
battleFoeAppeared: "A new challenger approaches!",
quizAstronomy: "Astronomy Question",
quizChemistry: "Chemistry Question",
quizSymbolQuestion: "Which Element has the symbol",
quizElementName: "Element Name",
quizFact: "Fact",
// New Mechanics (v1.8.2) - SRS & Evolution
dailyTraining: "Daily Training",
trainButton: "Train",
evolve: "Evolve",
evolutionReady: "Evolution Available!",
evolutionConfirm: "Evolve {word}?",
evolutionSuccess: "Congratulations! Your {word} evolved!",
chooseBranch: "Choose Evolution Path",
branchNoun: "Noun Branch",
branchVerb: "Verb Branch",
branchAdj: "Adjective Branch",
branchSelected: "{word} became a {branch}!",
fusionReady: "Fusion Available!",
familyFusion: "Family Fusion",
fusionAvailable: "Fusion Available!",
fusionConfirm: "Fuse {count} words from the {family} family?",
fusionSuccess: "Behold! {word} has been summoned!",
masteryRank: "Mastery Rank",
nextUnlock: "Next Unlock",
// Tech API Contexts
techDefContext7: "Technical Definition (Context7)",
techTermStack: "Technical Term (StackOverflow)"
},
ko: {
// Context Menu
contextMenu: "'%s' 잡기",
// Main UI
wordDex: "단어장",
darkMode: "다크",
lightMode: "라이트",
languageEN: "EN",
languageKO: "KO",
// Search & Controls
searchPlaceholder: "단어 검색...",
sortAlpha: "ABC순",
sortRecent: "최근순",
sortRarity: "희귀도순",
sortTag: "태그순",
// Filter Menu
filterMenuTitle: "태그 및 필터",
sortView: "정렬 방식",
sortByTags: "태그별 정렬",
sortByRarityAll: "희귀도별 정렬 (전체)",
filterByTag: "태그로 필터",
clearFilter: "필터 해제",
quiz: "퀴즈",
// Stats
collectionStats: "통계",
totalWords: "총 단어 수",
streak: "연속 출석일수",
longest: "최고 연속 출석일수",
day: "일",
days: "일",
// Rarities
common: "일반",
uncommon: "특이",
rare: "희귀",
epic: "영웅",
legendary: "전설",
mythic: "신화",
god: "신",
// Rarity Labels (for display)
COMMON: "일반",
UNCOMMON: "특이",
RARE: "희귀",
EPIC: "영웅",
LEGENDARY: "전설",
MYTHIC: "신화",
GOD: "신",
// Messages
noWordsMessage: "아직 수집한 단어가 없습니다. 웹에서 단어를 우클릭하여 수집을 시작하세요!",
noSearchResults: "검색 결과가 없습니다.",
deleteConfirm: "\"{word}\"을(를) 삭제하시겠습니까?",
deleteButton: "삭제",
infoButton: "정보",
// Charts
wordsCaughtLast7Days: "최근 1주 수집 단어",
rarityDistribution: "희귀도 분포",
// Badges
achievements: "업적",
hiddenBadges: "히든 업적",
maxLevel: "최고 레벨!",
nextBadge: "다음:",
// Badge Names
firstDay: "첫 날",
"7DayStreak": "1주 연속",
"10DayStreak": "10일 연속",
"30DayStreak": "1달 연속",
"100DayStreak": "100일 연속",
"365DayStreak": "1년 연속",
firstWord: "첫 단어",
"5Words": "5개 단어",
"10Words": "10개 단어",
"50Words": "50개 단어",
"100Words": "100개 단어",
"500Words": "500개 단어",
firstSite: "첫 사이트",
"5Sites": "5개 사이트",
"10Sites": "10개 사이트",
"50Sites": "50개 사이트",
"100Sites": "100개 사이트",
"500Sites": "500개 사이트",
firstMythic: "첫 신화!",
meta: "메타",
huh: "음???",
limbusCompany: "림버스 컴퍼니",
commonKiller: "일반 킬러",
uncommonKiller: "특이 킬러",
rareKiller: "희귀 킬러",
epicKiller: "영웅 킬러",
legendaryKiller: "전설 킬러",
mythicKiller: "신화 킬러",
// Quiz Mode
quizStart: "퀴즈 시작",
quizQuestion: "문제",
quizOf: "/",
quizDefinition: "정의:",
quizFillBlank: "빈칸 채우기:",
quizTheWordIs: "단어:",
quizSubmit: "제출",
quizSkip: "건너뛰기",
quizBack: "단어장으로",
quizTryAgain: "다시 시도",
quizCorrect: "정답! 단어는 \"{word}\"입니다.",
quizIncorrect: "오답. 정답은 \"{word}\"입니다.",
quizComplete: "퀴즈 완료!",
quizScore: "점수:",
quizPerfect: "완벽합니다! 단어를 잘 알고 있어요!",
quizGreat: "잘했어요! 대부분의 단어를 알고 있어요!",
quizGood: "좋아요! 계속 학습하세요!",
quizPractice: "계속 연습하세요! 단어를 더 자주 복습하세요.",
quizMinWords: "퀴즈를 시작하려면 최소 3개의 단어가 필요합니다. 더 많은 단어를 수집하세요!",
quizAnswerPlaceholder: "답을 입력하세요...",
// Quiz Menu
quizMenuTitle: "퀴즈 설정",
quizNumQuestions: "문제 수",
quizStartBtn: "퀴즈 시작",
// Error Messages
wordNotFound: "사전에서 단어를 찾을 수 없습니다",
apiError: "API 오류",
timeout: "요청 시간 초과. 다시 시도하세요.",
invalidWord: "잘못된 단어 형식입니다.",
tooShort: "단어는 최소 3글자 이상이어야 합니다.",
onlyLetters: "단어는 문자만 포함해야 합니다 (숫자나 특수문자 불가).",
couldNotFetch: "정의를 가져올 수 없습니다.",
apiKeyError: "등록되지 않은 인증 키",
systemError: "시스템 오류",
requestError: "잘못된 요청",
dailyLimitExcess: "일일 API 한도를 초과했습니다. 내일 다시 시도하세요.",
// Frequency Info
frequency: "빈도",
perMillion: "백만 당",
frequencyNA: "N/A (레거시 단어)",
sourceAPI: "API",
sourceLocalDB: "로컬 DB",
sourceKoreanAPI: "한국어 API",
// Animation Messages
gotIt: "확인",
tryAgain: "다시 시도",
newWordCaught: "새로운 단어를 잡았습니다!",
alreadyCaught: "이미 잡았습니다! 정의가 업데이트되었습니다",
firstCaughtOn: "처음 잡은 날:",
failedToCatch: "잡기 실패",
// New Features (Profile, Tabs, Battle)
tabDex: "단어장",
tabQuiz: "퀴즈",
tabBattle: "배틀",
tabProfile: "프로필",
// Word Types (Short)
type_n: "명사",
type_v: "동사",
type_adj: "형용사",
type_adv: "부사",
type_p: "대명사",
type_pre: "전치사",
type_conj: "접속사",
type_interj: "감탄사",
// Profile & Friends
profileOverview: "개요",
profileFriends: "친구",
friendRequests: "친구 요청",
friendPending: "보낸 요청",
friendWaiting: "대기 중...",
friendAdd: "추가",
friendPlaceholder: "사용자명 입력...",
battleChallenge: "배틀",
friendNotFound: "사용자를 찾을 수 없습니다",
friendSelf: "자신을 추가할 수 없습니다!",
friendExists: "이미 친구이거나 요청을 보냈습니다.",
requestSent: "요청이 전송되었습니다!",
requestError: "요청 전송 오류",
// Customization
editProfile: "프로필 편집",
custTitle: "칭호",
custAvatar: "아바타",
// Profile
profileRating: "레이팅",
profileWins: "승",
profileLosses: "패",
profileWords: "수집한 단어",
profileTeam: "방어팀",
profileSave: "팀 저장",
profileBack: "단어장으로",
profileLoginReq: "배틀을 하려면 로그인이 필요합니다!",
profileTeamReq: "프로필에서 팀을 먼저 설정하세요!",
profileSaving: "저장 중...",
profileSaved: "저장됨!",
profileSaveFail: "팀 저장 실패",
profileLoading: "프로필 로딩 중...",
profileError: "프로필 로딩 오류. 로그인 해주세요.",
forceBackup: "데이터 백업",
// Battle
battleStart: "배틀 시작!",
battleRun: "도망가기",
battleVS: "VS 상대",
battleVictory: "승리!",
battleDefeat: "패배...",
battleFainted: "{word} 기절!",
battleAttacks: "{attacker} 공격! {damage} 데미지!",
battleBack: "메뉴로",
battleArena: "배틀 아레나",
battleRandom: "랜덤 배틀",
battleFriendId: "트레이너 ID / 이름",
battleGo: "ㄱ",
battleCancel: "취소",
battleSearching: "상대 찾는 중...",
battleFoeAppeared: "새로운 도전자가 나타났다!",
quizAstronomy: "천문학 퀴즈",
quizChemistry: "화학 퀴즈",
quizSymbolQuestion: "다음 원소 기호의 이름은 무엇입니까:",
quizElementName: "원소 이름",
quizFact: "설명",
// New Mechanics (v1.8.2) - SRS & Evolution
dailyTraining: "일일 훈련",
trainButton: "훈련",
evolve: "진화",
evolutionReady: "진화 가능!",
evolutionConfirm: "{word}을(를) 진화시키겠습니까?",
evolutionSuccess: "축하합니다! {word}이(가) 진화했습니다!",
chooseBranch: "진화 경로 선택",
branchNoun: "명사 경로",
branchVerb: "동사 경로",
branchAdj: "형용사 경로",
branchSelected: "{word}(이)가 {branch}(으)로 진화했습니다!",
fusionReady: "융합 가능!",
familyFusion: "패밀리 융합",
fusionAvailable: "융합 가능!",
fusionConfirm: "{family} 패밀리의 단어 {count}개를 융합하시겠습니까?",
fusionSuccess: "보라! {word}(이)가 소환되었습니다!",
masteryRank: "마스터리 랭크",
nextUnlock: "다음 잠금 해제",
// Tech API Contexts
techDefContext7: "기술 정의 (Context7)",
techTermStack: "기술 용어 (StackOverflow)"
}
};
// Current language state (will be loaded from storage)
let currentLanguage = 'en';
// Get current language from storage
async function getCurrentLanguage() {
return new Promise((resolve) => {
if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local) {
chrome.storage.local.get(['language'], (data) => {
currentLanguage = data.language || 'en';
resolve(currentLanguage);
});
} else {
resolve(currentLanguage);
}
});
}
// Set language and save to storage
async function setLanguage(lang) {
if (!translations[lang]) {
console.error(`Language "${lang}" not supported`);
return false;
}
currentLanguage = lang;
return new Promise((resolve) => {
if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local) {
chrome.storage.local.set({ language: lang }, () => {
resolve(true);
});
} else {
resolve(true);
}
});
}
// Translate a key to current language
function t(key, replacements = {}) {
const translation = translations[currentLanguage]?.[key] || translations['en']?.[key] || key;
// Replace placeholders like {word}
let result = translation;
for (const [placeholder, value] of Object.entries(replacements)) {
result = result.replace(`{${placeholder}}`, value);
}
return result;
}
// Synchronous version of translate (uses current language state)
// Use this when you need immediate translation without async
function tSync(key, replacements = {}) {
return t(key, replacements);
}
// Initialize language on script load
if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local) {
chrome.storage.local.get(['language'], (data) => {
currentLanguage = data.language || 'en';
console.log('Lingomon i18n: Language loaded:', currentLanguage);
});
// Listen for language changes
chrome.storage.onChanged.addListener((changes, areaName) => {
if (areaName === 'local' && changes.language) {
currentLanguage = changes.language.newValue || 'en';
console.log('Lingomon i18n: Language changed to:', currentLanguage);
}
});
}
// Export for use in other scripts
if (typeof module !== 'undefined' && module.exports) {
module.exports = { getCurrentLanguage, setLanguage, t, tSync };
}