Kai72828 commited on
Commit
52a7593
·
verified ·
1 Parent(s): da0686b

Upload 11 files

Browse files
Files changed (1) hide show
  1. translation.py +192 -423
translation.py CHANGED
@@ -207,366 +207,208 @@ def _chunk(lst: list, size: int) -> list:
207
 
208
 
209
  # ─────────────────────────────────────────────────────────────────────────────
210
- # Prompts — Multi-Preset System
 
 
 
 
 
 
211
  # ─────────────────────────────────────────────────────────────────────────────
212
 
213
- # Shared rules appended to every preset (non-negotiable technical rules)
214
- _BASE_RULES = """
215
- ━━ CRITICAL: COUNT RULE ━━
216
- Input N numbered items → Output EXACTLY N items
217
- NEVER merge 2 inputs → 1 output (blank screen bug ဖြစ်)
218
- NEVER split 1 input → 2 outputs (timestamp shift ဖြစ်)
219
- Short line → keep short | Long line → translate as single item
220
-
221
- ━━ TECHNICAL ━━
222
- • ASS override tags ({\\an8}, {\\pos(...)}, {\\be5}, {\\fad(...)} etc.) + music ♪ + newline marker ⏎ → preserve exactly
223
- • Glossary term ပါက → Glossary ထဲက term ကိုသာ တိတိကျကျ သုံးရမည် — ကွဲလွဲမည့် ဘာသာပြန် မသုံးရ
224
-
225
- ━━ GOOD vs BAD EXAMPLES ━━
226
- ❌ "ဒါသည် ကောင်းမွန်သောရလဒ်တစ်ခုဖြစ်သည်" → literal / formal / AI-ish
227
- ✅ "ဒါကတော့ ကောင်းတဲ့ outcome ပဲ" → natural spoken
228
- ❌ "သင်သည် ဤနေရာတွင် ဘာကြောင့်ရှိနေသနည်း" → English word order
229
- ✅ "မင်း ဒီမှာ ဘာလာလုပ်တာလဲ" → Myanmar natural order
230
- ❌ "ကျွန်ုပ်ကို ကူညီပေးပါ၊ ကျေးဇူးပြု၍" → မပါတာ ဖြည့်ထည့် (AI padding)
231
- ✅ "ကူညီပါ" → source: "Help me!" — concise
232
-
233
- ━━ OUTPUT FORMAT ━━
234
- JSON array only. EXACTLY n items. No markdown, no preamble, no explanation.
235
- ["ဘာသာပြန် ၁", "ဘာသာပြန် ၂", ..., "ဘာသာပြန် n"]
236
- """
237
-
238
- # ── Preset bodies ─────────────────────────────────────────────────────────────
239
 
240
- _PRESET_STANDARD = """
241
- သင်သည် Movie / Series / Cartoon subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်။
242
- Netflix / Disney subtitle localization standard ကို ကျင့်သုံးသည်။
243
- General audience — All ages / family-friendly content အတွက် သင့်တော်သောဘာသာပြန်ချက်ပေးသည်။
244
 
245
- ━━ CORE PHILOSOPHY ━━
246
- Subtitle = တ်ကေင်ပြသောစကားတိုတို၊ ထိရောက်၊ သဘာဝကျ
247
- မပြောရဘဲ မဖြည့်ရ။ ပြောတာကို မနုတ်ရ။ AI ဘာသာပြန်မှန်းသိ့ — human နှင့် မခွဲနိုင်ဖြစ်စေ
248
 
249
- ━━ PERSONA ━━
250
- တ်က voice ကို ထုတပေသည် AI voice မဟုတ်
251
- • Hero / main → သာမန် natural ပြောဆို
252
- • Comic → ပေါ့ပေါ့ပါးပါး colloquial
253
- • Formal / Elder → လေးလေးနက်နက်
254
- • Villain → ကြမ်းတမ်းသော်လည်း family-safe
255
-
256
- ━━ LANGUAGE REGISTER ━━
257
- • ယောက်ျားကြမ်း → ငါ/မင်း + ကွ/ဗျ/ကွာ
258
  ��� မိန်းကလေး → ကျမ/ငါ + ကွာ/ဟေ့
259
- • Elder / boss → ကျွန်တော်/ကျွန်မ formal
260
- ဟာသ → ပြောပြောဆိုဆို colloquial
261
-
262
- ━━ TRANSLATION RULES ━━
263
- 1. Literal structure ရှောင် — မြန်မာ speaker ဒီ situation မှာ ဘာပြောမည်ကို တွေး
264
- 2. မပိုထည့်ရ — source မပါ = မထည့်
265
- 3. မနုတ်ရ — emphasis / emotion မပယ်ရ
266
- 4. ဆဲစကား / ကြမ်း → mild မြန်မာ equivalent (မဆဲရ — family-safe ဖြစ်ရမည်)
267
- 5. Subtitle brevity — ၁ event = ၁ ကြောင်း
268
- 6. Character consistency — same ဇာတ်ကောင် = same pronoun + speech style
269
-
270
- ━━ PROPER NOUNS ━━
271
- ဇာတ်ကောင်နာမည် / နေရာနာမည် / အဖွဲ့နာမည် → ENGLISH မူရင်း spelling သာ (မဘာသာမပြန်ရ)
272
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → English မူရင်း spelling
273
  """
274
 
275
- _PRESET_ADULT_18 = """
276
- သငသည် Movie / Series / Anime / Cartoon subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်
277
- Crunchyroll / Netflix anime localization standard ကို ကျင့်သုံးသည်။
278
- Mature / 18+ content — ဇာတ်လမ်း၏ အနှစ်သာရ၊ ဘာသာပြောနညးစနစ် ကို အပြည့်အဝ ိန်းသိမ်းသည်။
279
-
280
- ━━ CORE PHILOSOPHY ━━
281
- Subtitle = ဇာတ်ကော်ပြောသောစကာ— တိုတိ၊ ထိရောက သဘာဝကျ
282
- ပြောရဘဲ မဖြည့်ရ။ ပြောတာကို မနုတ်ရ။ AI ဘာသာပြန်မှန်းသ့ — human နှင့် မခွဲနိင်ဖြစ်စေ
283
-
284
- ━━ PERSONA ━━
285
- ဇာတ်ကောင်၏ voice ကို ထုတ်ပေးသည် AI voice မဟုတ်
286
- • Tough/villain → ကြမ်းတမ်းသောပြောဆို
287
- • Gentle/romantic → နူးညံ့သောပြောဆို
288
- • Comic → ပေါ့ပေါ့ပါးပါး
289
- • Formal elder/boss → လေးလေးနက်နက်
290
-
291
- ━━ LANGUAGE REGISTER ━━
292
- • ယောက်ျားကြမ်း / villain / ဂိုဏ်း → ငါ / မင်း / ကောင် + particle: ကွ/ဗျ/ကွာ
293
- • မိန်းကလေး ရင်းနှီး → ကျမ/ငါ / မင်း/နင် + particle: ကွာ/ဟေ့
294
- • Boss/တောင်ကြည့် → ငါ / မင်း (ပြင်းထန်) သို့မဟုတ် ကျွန်တော် (formal)
295
- • ဟာသ/ပေါ့ → ပြောပြောဆိုဆို colloquial
296
-
297
- ━━ TRANSLATION RULES ━━
298
- 1. Literal structure ရှောင် — မြန်မာ speaker ဒီ situation မှာ ဘာပြောမည်ကို တွေး
299
- 2. မပိုထည့်ရ — source မပါ = မထည့်
300
- 3. မနုတ်ရ — source မှာပါသော emphasis / emotion မပယ်ရ
301
- 4. ဆဲစကား / 18+ / ကြမ်း — EN source → English ထားပါ (Fuck / Shit / Bitch / Bastard)
302
- Other lang → closest English equivalent ဖြင့်ထားပါ
303
- 5. Subtitle brevity — ၁ event = ၁ ဘာသာပြန်ကြောင်း
304
- 6. Character consistency — same ဇာတ်ကောင် = same pronoun + speech style တစ်ကျပ်တည်း
305
-
306
- ━━ PROPER NOUNS ━━
307
- ဇာတ်ကောင်နာမည် / မြို့နာမည် / ကျွန်းနာမည် / နေရာနာမည် / အဖွဲ့နာမည် → ENGLISH မူရင်း spelling
308
- • "Victor" → "Victor" ❌ မဟုတ်ပါ "ဗစ်တာ" | "Hope Street" → "Hope Street"
309
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → English မူရင်း spelling
310
  """
311
 
312
- _PRESET_ANIME = """
313
- သငသည် Anime / Manga / Light Novel subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်။
314
- Crunchyroll anime localization standard ကို ကျင့်သုံးသည်။
315
- Japanese anime culture ၏ အနှစ်သာရကို မပျောက်စေဘဲ မြန်မာဘာသာပြန်ပေးသ
316
-
317
- ━━ ANIME-SPECIFIC ━━
318
- Japanese honorifics: -san, -kun, -chan, -sama, -senpai, -sensei, -dono, -nii, -nee, -hime
319
- context ကြည့်ပြီး keep သို့မဟုတ် natural ြန်မာ equivalent (Glossary ပါလျှင် Glossary အတိုင်)
320
- Anime/otaku terms: baka, kawaii, tsundere, nakama, nani, sugoi, etc. English ထးပါ
321
- Fantasy/Isekai system terms: HP, MP, Level, Skill, Quest, Status, Guild → English ထားပါ
322
- • Japanese sound effects (ara ara, yare yare etc.) → keep သို့မဟုတ် closest မြန်မာ feel
323
-
324
- ━━ CORE PHILOSOPHY ━━
325
- Subtitle = ဇာတ်ကောင်ပြောသောစကား — တိုတို၊ ထိရောက်၊ သဘာဝကျ
326
- Anime character vocal styles (Tsundere/Kuudere/Genki/Chuunibyou) ကို ထိန်းသိမ်းပါ
327
-
328
- ━━ PERSONA ━━
329
- • Energetic/shonen → ဇာတိကျ ဂုဏ်သိက္ခာ colloquial
330
- • Tsundere → တည်ငြိမ်ပြီး ဒေါသကျ voice
331
- • Kuudere/Cool → ပြတ်သားတိုနည်း
332
- • Villain/boss → ကြမ်းတမ်း ပြင်းထန်
333
- • Cute/moe → နူးညံ့ ကလေးဆန်
334
-
335
- ━━ LANGUAGE REGISTER ━━
336
- • ကောင်ကြမ်း / shonen → ငါ/မင်း + ကွ/ဗျ/ကွာ
337
- • မိန်းကလေး → ကျမ/ငါ + ကွာ/ဟေ့
338
- • Formal/elder/sensei → ကျွန်တော်/ရှင်
339
- • ဟာသ character → ပြောပြောဆိုဆို colloquial
340
-
341
- ━━ TRANSLATION RULES ━━
342
- 1. Literal structure ရှောင် — natural မြန်မာ word order
343
- 2. မပိုထည့်ရ — source မပါ = မထည့်
344
- 3. မနုတ်ရ — emphasis / emotion မပယ်ရ
345
- 4. ဆဲစကား / 18+ → English ထားပါ (Fuck/Shit/Bitch)
346
- 5. Subtitle brevity — ၁ event = ၁ ကြောင်း
347
- 6. Character consistency
348
-
349
- ━━ PROPER NOUNS ━━
350
- Japanese names/places → Romaji မူရင်း spelling (e.g. "Naruto", "Tokyo", "Konoha", "Sasuke")
351
- မြန်မာ phonetic မရေးရ — "Naruto" not "နာရုတို"
352
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → Romaji / English မူရင်း
353
  """
354
 
355
- _PRESET_CDRAMA = """
356
- သငသည် Chinese Drama / Movie / Wuxia / Xianxia subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်
357
- Chinese cultural context ကို preserve လုပ်ပြီး မြန်မာ audience နားလည်စေရန် ဘာသာပြန်သည်။
358
- Chinese drama dramatic tone, poetic expression, formal hierarchy ကို မပျောက်စေဘဲ ဘာသာပြန်ပေးသ
359
-
360
- ━━ CHINESE-SPECIFIC ━━
361
- • Chinese names → Pinyin romanization (e.g. "Wei Wuxian", "Lan Wangji", "Zhao Liying")
362
- မြန်မာ phonetic မရေးရ — "Wei Wuxian" not "ဝေဝူရှျား"
363
- • Relationship/title terms → Pinyin/English ထားပါ:
364
- Shifu (master), Shidi/Shixiong/Shijie (junior/senior disciples), Gege/Jiejie/Meimei (siblings)
365
- A'niang/Niang (mother), Wangye (prince), Gongzi (young master), Guniang (young lady)
366
- Shifu → "Shifu" | Gege → "Gege" | Wangye → "Wangye"
367
- • Wuxia/Xianxia terms → English/Pinyin:
368
- Golden Core, Nascent Soul, cultivation, qi, meridians, sect, immortal, demon
369
- • Historical titles → English: Emperor, Empress, Crown Prince, Noble Consort, Grand Vizier
370
-
371
- ━━ CORE PHILOSOPHY ━━
372
- Chinese drama feel ကို ထိန်းသိမ်းပါ — formal yet emotional, dramatic pacing, layered meaning
373
- Cultural nuances ကို မဖျက်ပစ်ရ | Poetic lines → equivalent Myanmar poetic feel
374
-
375
- ━━ PERSONA ━━
376
- • Emperor/high noble → formal, dignified, restrained မြန်မာ
377
  • Common folk → သာမန် colloquial
378
- • Villain/schemer → ကြမ်းတမ်း ပြတ်သား
379
- • Romantic leads → နူးညံ့ emotion-laden
380
-
381
- ━━ LANGUAGE REGISTER ━━
382
- • ယောက်ျားကြမ်း → ငါ/မင်း + ကွ/ဗျ
383
- • Noble/formal male → ကျွန်တော် formal
384
- • Noble/formal female → ကျွန်မ formal
385
- • Common folk → colloquial natural
386
-
387
- ━━ TRANSLATION RULES ━━
388
- 1. Natural မြန်မာ — literal Chinese sentence structure ရှောင်
389
- 2. မပိုထည့်ရ — source မပါ = မထည့်
390
- 3. မနုတ်ရ — cultural weight / dramatic moment မပျောက်ရ
391
- 4. ဆဲစကား → Chinese dramas: context-appropriate mild equivalent
392
- 5. Subtitle brevity — ၁ event = ၁ ကြောင်း
393
- 6. Character consistency
394
-
395
- ━━ PROPER NOUNS ━━
396
- Chinese names/places/sects → Pinyin မူရင်း (e.g. "Yunmeng Jiang Sect", "Cloud Recesses", "Wei Ying")
397
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → Pinyin / English မူရင်း spelling
398
  """
399
 
400
- _PRESET_KDRAMA = """
401
- သငသည် Korean Drama / Movie / Webtoon subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်
402
- Korean cultural context ကို preserve လုပ်ပြီး မြန်မာ audience နားလည်စေရန် ဘာသာပြန်သည်။
403
- K-drama emotional intensity, modern slang, hierarchical speech levels ကို မပျောက်စေဘဲ ဘာသာပြန်သည်။
404
-
405
- ━━ KOREAN-SPECIFIC ━━
406
- Korean namesRomanized Korean (e.g. "Park Seo-jun", "Kim Ji-won", "Lee Min-ho")
407
- မြန်မာ phonetic မရေးရ "Park Seo-jun" not "ါ့ဆေဂွန"
408
- Relationship/honorific terms → English ထားပါ:
409
- Oppa (older bro/boyfriend - female speech), Unnie (older sis - female speech)
410
- Hyung (older bro - male speech), Noona (older sis - male speech)
411
- Sunbae (senior), Hoobae (junior), Sajangnim (CEO/boss), Seonsaengnim (teacher)
412
- • Korean food/culture refs → English/romanized: Ramyeon, Tteokbokki, Hanbok, Jjimjilbang
413
- • Speech levels: Korean 존댓말 (formal) → formal မြန်မာ | 반말 (informal) → colloquial မြန်မာ
414
- • Aegyo expressions → nearest natural မြန်မာ cute equivalent
415
-
416
- ━━ CORE PHILOSOPHY ━━
417
- K-drama emotional intensity ကို ထိန်းသိမ်းပါ — passionate, sincere, sometimes melodramatic
418
- Contemporary Korean feel — modern, relatable, emotionally resonant
419
-
420
- ━━ PERSONA ━━
421
- • Chaebol/CEO → formal, cold, measured
422
- • Young common adult → modern colloquial
423
- • Elder/parent → authoritative, caring
424
- • Romantic lead → emotional, sincere, expressive
425
-
426
- ━━ LANGUAGE REGISTER ━━
427
- • ယောက်ျားကြမ်း → ငါ/မင်း + ကွ/ဗျ
428
- • Modern young female → ငါ/ကျမ + ကွာ/ဟေ့
429
- • Senior/formal → ကျွန်တော်/ကျွန်မ formal
430
- • Elder → respectful register
431
-
432
- ━━ TRANSLATION RULES ━━
433
- 1. Natural မြန်မာ — literal Korean structure ရှောင်
434
- 2. မပိုထည့်ရ — source မပါ = မထည့်
435
- 3. မနုတ်ရ — Korean dramatic emphasis မပျောက်ရ
436
- 4. ဆဲစကား / 18+ → English ထားပါ
437
- 5. Subtitle brevity — ၁ event = ၁ ကြောင်း
438
- 6. Character consistency
439
-
440
- ━━ PROPER NOUNS ━━
441
- Korean names/places → Romanized Korean မူရင်း (e.g. "Seoul", "Gangnam", "Incheon Airport")
442
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → Romanized Korean / English မူရင်း
443
  """
444
 
445
- _PRESET_FORMAL = """
446
- သငသည် Documentary / News / Educational / Narration subtitle ဘာသာပြန်ပညာရှင်တစ်ဦးဖြစ်သည်
447
- BBC / NHK World documentary localization standard ကို ကျင့်သုံးသည်။
448
- Objective, accurate, formal register ဖြင့် ဘာသာပြန်ပေးသည်။
449
-
450
- ━━ CORE PHILOSOPHY ━━
451
- Accuracy first meaning အတအကထိနးသိမ်းပါ
452
- Narrator voice objective, informative, dignified, educational
453
- Colloquialism ရှောင် — educated standard Myanmar register
454
-
455
- ━━ REGISTER ━━
456
- • Narration → formal standard Myanmar (ပညာတတ် register)
457
- • Expert interview quotes → semi-formal educated register
458
- • On-screen subject dialogue → natural but restrained formal
459
- • Technical explanation → precise, clear, accessible
460
-
461
- ━━ TRANSLATION RULES ━━
462
- 1. Accuracy first — factual meaning အတိအကျ
463
- 2. Technical terms → precise Myanmar equivalent ထားပါ; မရှိလျှင် (English term) ပြင်ပကွင်းတွင်ထည့်
464
- 3. Statistics / numbers / dates → exact translation
465
- 4. Scientific names → English မူရင်း + Myanmar explanation if needed
466
- 5. မပိုထည့်ရ — မနုတ်ရ (factual content ဖြစ်သောကြောင့် accuracy သည် အရေးကြီး)
467
- 6. Subtitle brevity — readable narration pace
468
-
469
- ━━ PROPER NOUNS ━━
470
- Names/places/organizations → English မူရင်း spelling (e.g. "United Nations", "Amazon River", "Einstein")
471
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → English မူရင်း spelling
472
  """
473
 
474
- # ── Source Culture Addenda ────────────────────────────────────────────────────
475
- # Short culture-specific notes appended to ANY preset to handle origin language
476
 
477
- _CULTURE_WESTERN = "" # default — no addendum needed
478
 
479
- _CULTURE_JAPANESE = """
480
- ━━ SOURCE CULTURE: Japanese ━━
481
- content သည် Japanese (日本語) source မှ ာသာပြန်းသော English subtitle ဖြစသည်။
482
- Japanese names/places Romaji မူရင်း spelling ထားပါ (e.g. "Yamamoto", "Osaka", "Sakura")
483
- မြန်မာ phonetic မရေးရ "Tanaka" not "တနာကာ"
484
- Japanese honorifics in English subtitles (-san, -kun, -chan, -senpai etc.) → keep as-is
485
- Japanese cultural terms (onsen, matsuri, bento, etc.) → English/Romaji ထားပါ
486
  """
487
 
488
- _CULTURE_CHINESE = """
489
- ━━ SOURCE CULTURE: Chinese ━━
490
- content သည် Chinese (中文) source မှ ဘာသာပြန်ထားသော English subtitle ဖြစ်သည်။
491
- Chinese names/places Pinyin romanization ထားပါ (e.g. "Li Wei", "Beijing", "Sichuan")
492
- မြန်မာ phonetic မရေးရ "Zhang Wei" not "ကျန်းဝေ"
493
- Chinese relationship terms in English subs Pinyin/English ထားပါ (Gege/Shifu/etc.)
494
- Chinese cultural/food termsPinyin/English ထားပါ (hotpot, Qipao, Mahjong, etc.)
495
  """
496
 
497
- _CULTURE_KOREAN = """
498
- ━━ SOURCE CULTURE: Korean ━━
499
- content သည် Korean (한국어) source မှ ဘာသာပြန်ထားသော English subtitle ဖြစ်သည်။
500
- Korean names/places Romanized Korean မူရင်း ထားပါ (e.g. "Kim Taehyung", "Busan", "Jeju")
501
- မြန်မာ phonetic မရေးရ "Yoon" not "ယွန်"
502
- Korean relationship terms in English subs English/Romanized ထားပါ (Oppa/Unnie/etc.)
503
- Korean cultural terms → English/romanized ထားပါ (Hanok, Ssireum, Hangul, etc.)
504
  """
505
 
506
- _CULTURE_THAI = """
507
- ━━ SOURCE CULTURE: Thai / Southeast Asian ━━
508
- content သည် Thai / Southeast Asian source ဘာသာပြန်းသော English subtitle ဖြစ်သည်။
509
- Thai/SE Asian names/placesromanized မူရင်း ထားပါ (e.g. "Prayuth", "Chiang Mai", "Muay Thai")
510
- မြန်မာ phonetic မရေးရ
511
- Thai honorifics (Khun, Phi, Nong) → English ထားပါ သို့မဟုတ် natural Myanmar equivalent
512
- Thai cultural terms → English/romanized ထားပါ (Wai, Songkran, Tuk-tuk, etc.)
513
  """
514
 
515
- _CULTURE_UNIVERSAL = "" # mixed/unknown — no addendum
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
 
 
 
 
 
 
 
 
517
 
518
- # ── Master presets registry ───────────────────────────────────────────────────
 
 
 
 
 
 
 
 
 
519
 
520
  PROMPT_PRESETS: dict = {
521
- "standard": {
522
- "label": "🎬 Standard",
523
- "desc": "General audience movie, series, cartoon (family-safe)",
524
- "body": _PRESET_STANDARD,
525
- },
526
- "adult_18": {
527
- "label": "🔞 18+ Adult",
528
- "desc": "Mature content — strong language kept in English",
529
- "body": _PRESET_ADULT_18,
530
- },
531
- "anime": {
532
- "label": "⛩ Anime / J-Drama",
533
- "desc": "Japanese anime, manga adaptations, light novels",
534
- "body": _PRESET_ANIME,
535
- },
536
- "cdrama": {
537
- "label": "🏮 C-Drama / Movie",
538
- "desc": "Chinese drama, wuxia, xianxia, Chinese movies",
539
- "body": _PRESET_CDRAMA,
540
- },
541
- "kdrama": {
542
- "label": "🌸 K-Drama / Movie",
543
- "desc": "Korean drama, webtoon adaptations, Korean movies",
544
- "body": _PRESET_KDRAMA,
545
- },
546
- "formal": {
547
- "label": "📰 Documentary / Formal",
548
- "desc": "News, documentary, educational, narration content",
549
- "body": _PRESET_FORMAL,
550
- },
551
- "custom": {
552
- "label": "✏️ Custom",
553
- "desc": "Write your own system prompt",
554
- "body": "", # user provides via custom_text
555
- },
556
  }
557
 
558
  SOURCE_CULTURES: dict = {
559
- "western": {"label": "🌍 Western", "desc": "English/European productions", "addendum": _CULTURE_WESTERN},
560
- "japanese": {"label": "🇯🇵 Japanese", "desc": "Anime, J-Drama, Japanese movies", "addendum": _CULTURE_JAPANESE},
561
- "chinese": {"label": "🇨🇳 Chinese", "desc": "C-Drama, Chinese movies, Donghua", "addendum": _CULTURE_CHINESE},
562
- "korean": {"label": "🇰🇷 Korean", "desc": "K-Drama, Korean movies", "addendum": _CULTURE_KOREAN},
563
- "thai": {"label": "🇹🇭 Thai / SE Asian", "desc": "Thai drama, Southeast Asian content", "addendum": _CULTURE_THAI},
564
- "universal": {"label": "🌐 Unknown / Mixed", "desc": "Multi-cultural or unknown origin", "addendum": _CULTURE_UNIVERSAL},
565
  }
566
 
567
-
568
  PROPER_NOUN_STYLES: dict = {
569
- "english": {
570
  "label": "🔤 English / Romanized (မူရင်း spelling)",
571
  "desc": "Victor, Sakura, Hope Street — မြန်မာ phonetic မပြောင်း (default)",
572
  },
@@ -577,120 +419,47 @@ PROPER_NOUN_STYLES: dict = {
577
  }
578
 
579
 
580
- def _proper_noun_rule(style: str = "english", culture_key: str = "western") -> str:
581
- """
582
- Return the PROPER NOUNS instruction block to append to any preset.
583
- style: "english" → keep original spelling | "phonetic" → Myanmar phonetic
584
- """
585
- # Culture-specific romanization labels
586
- romanization = {
587
- "japanese": "Romaji",
588
- "chinese": "Pinyin",
589
- "korean": "Romanized Korean",
590
- "thai": "Romanized Thai",
591
- "western": "English",
592
- "universal": "original romanized",
593
- }.get(culture_key, "original romanized")
594
-
595
- if style == "phonetic":
596
- return f"""━━ PROPER NOUNS — PHONETIC MODE ━━
597
- ဇာတ်ကောင်နာမည် / မြို့နာမည် / နေရာနာမည် / အဖွဲ့နာမည် → မြန်မာ PHONETIC (အသံထွက်) ရေးရမည်
598
- အဓိပ္ပာယ်ဖြင့် ဘာသာမပြန်ရ — Phonetic transcription သာ
599
- • Victor → ဗစ်တာ ❌ မဟုတ်ပါ "Victor" / "အနိုင်ရသူ"
600
- • Sakura → ဆာကူရာ ❌ မဟုတ်ပါ "Sakura" / "ချယ်ရီပန်း"
601
- • Hope Street → ဟုတ်ပ်စထရိတ် ❌ မဟုတ်ပါ "Hope Street" / "မျှော်လင့်ချက်လမ်း"
602
- • Kim Taehyung → ကင်းတဲဟြုင်း ❌ မဟုတ်ပါ "Kim Taehyung"
603
- • Wei Wuxian → ဝေဝူရှျား ❌ မဟုတ်ပါ "Wei Wuxian"
604
- Proper noun ဟုတ်မဟုတ် မသေချာ → context ကြည့်ပြီး Phonetic ရေး
605
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → Phonetic transliteration"""
606
- else:
607
- return f"""━━ PROPER NOUNS — ENGLISH / {romanization.upper()} MODE ━━
608
- ဇာတ်ကောင်နာမည် / မြို့နာမည် / နေရာနာမည် / အဖွဲ့နာမည် → {romanization} မူရင်း spelling အတိုင်း ထားရမည်
609
- မြန်မာ phonetic မရေးရ — မဘာသာမပြန်ရ
610
- • Victor → "Victor" ❌ မဟုတ်ပါ "ဗစ်တာ" / "အနိုင်ရသူ"
611
- • Sakura → "Sakura" ❌ မဟုတ်ပါ "ဆာကူရာ" / "ချယ်ရီပန်း"
612
- • Hope Street → "Hope Street" ❌ မဟုတ်ပါ "ဟုတ်ပ်စထရိတ်" / "မျှော်လင့်ချက်လမ်း"
613
- • Wei Wuxian → "Wei Wuxian" ❌ မဟုတ်ပါ "ဝေဝူရှျား"
614
- • Kim Taehyung → "Kim Taehyung" ❌ မဟုတ်ပါ "ကင်းတဲဟြုင်း"
615
- Proper noun ဟုတ်မဟုတ် မသေချာ → context ကြည့်ပြီး {romanization} spelling ထားပါ
616
- Glossary ပါလျှင် → Glossary အတိုင်း | မပါ → {romanization} မူရင်း spelling"""
617
-
618
-
619
  def build_system_prompt(
620
- preset_key: str = "adult_18",
621
- culture_key: str = "western",
622
- custom_text: str = "",
623
- proper_noun_style: str = "english", # "english" | "phonetic"
624
  ) -> str:
625
  """
626
- Combine preset body + culture addendum + proper noun rule + shared base rules.
627
- For "custom" preset: custom_text is used as the full body.
 
628
  """
629
- preset = PROMPT_PRESETS.get(preset_key, PROMPT_PRESETS["adult_18"])
630
- culture = SOURCE_CULTURES.get(culture_key, SOURCE_CULTURES["western"])
631
-
632
  if preset_key == "custom":
633
- body = custom_text.strip() if custom_text.strip() else PROMPT_PRESETS["adult_18"]["body"]
634
- else:
635
- body = preset["body"]
636
-
637
- # Strip any hardcoded PROPER NOUNS section from preset body
638
- # (we inject the dynamic one below)
639
- import re as _re
640
- body_clean = _re.sub(
641
- r'━━ PROPER NOUNS[^━]*(?=━━|\Z)', '', body, flags=_re.DOTALL
642
- ).strip()
643
-
644
- addendum = culture["addendum"]
645
- noun_rule = _proper_noun_rule(proper_noun_style, culture_key)
646
-
647
- parts = [body_clean]
648
- if addendum.strip():
649
- parts.append(addendum.strip())
650
- parts.append(noun_rule)
651
- parts.append(_BASE_RULES.strip())
652
-
653
  return "\n\n".join(parts)
654
 
655
 
656
  def _sys_glossary_for_culture(
657
- culture_key: str = "western",
658
  proper_noun_style: str = "english",
659
  ) -> str:
660
- """Return culture-aware glossary extraction prompt."""
661
- romanization = {
662
- "japanese": "Romaji",
663
- "chinese": "Pinyin",
664
- "korean": "Romanized Korean",
665
- "thai": "Romanized Thai",
666
- "western": "English",
667
- "universal": "original romanized",
668
- }.get(culture_key, "original romanized")
669
-
670
- if proper_noun_style == "phonetic":
671
- noun_rule = (
672
- "PROPER NOUN RULE — PHONETIC MODE:\n"
673
- " All proper nouns (names, places, organizations) → Myanmar PHONETIC transliteration.\n"
674
- " e.g. 'Victor' → 'ဗစ်တာ' | 'Sakura' → 'ဆာကူရာ' | 'Wei Wuxian' → 'ဝေဝူရှျား'\n"
675
- " NEVER keep English/romanized spelling for proper nouns.\n"
676
- " NEVER translate by meaning.\n"
677
- "For recurring slang/special terms: provide Myanmar မြန်မာ translation as value.\n"
678
- 'Return ONLY JSON: {"English term": "Myanmar phonetic or မြန်မာ translation"}'
679
- )
680
- else:
681
- noun_rule = (
682
- f"PROPER NOUN RULE — {romanization.upper()} MODE:\n"
683
- f" All proper nouns → {romanization} original spelling. NEVER transliterate into Myanmar script.\n"
684
- f" e.g. 'Victor' → 'Victor' | 'Sakura' → 'Sakura' | 'Wei Wuxian' → 'Wei Wuxian'\n"
685
- "For recurring slang/special terms: provide Myanmar မြန်မာ translation as value.\n"
686
- f'Return ONLY JSON: {{"{romanization} term": "{romanization} or မြန်မာ value"}}'
687
- )
688
-
689
  return (
690
- "Extract Myanmar subtitle translation glossary from subtitle lines.\n"
691
- "Include: character names, place names (cities, islands, streets, buildings), "
692
- "organization names, recurring slang/special terms.\n\n"
693
- + noun_rule
 
 
694
  )
695
 
696
 
 
207
 
208
 
209
  # ─────────────────────────────────────────────────────────────────────────────
210
+ # Prompts — Multi-Preset System (revamped: zero redundancy, each rule said once)
211
+ #
212
+ # Architecture: build_system_prompt() assembles 4 non-overlapping layers:
213
+ # 1. STYLE — tone / register / swearing (preset-specific)
214
+ # 2. TERMS — special terms to preserve (culture-specific)
215
+ # 3. NOUNS — proper noun handling (noun_style × culture, generated once)
216
+ # 4. TECH — count rule / tags / glossary / output (always identical)
217
  # ─────────────────────────────────────────────────────────────────────────────
218
 
219
+ # ── Layer 1: STYLE blocks (preset-specific) ───────────────────────────────────
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
+ # Header is generated dynamically from preset + culture — not hardcoded here.
222
+ # Each STYLE block covers only: register, tone, swearing policy.
223
+ # "Don't add / don't remove" is stated once globally in TECH — not repeated here.
 
224
 
225
+ _STYLE_STANDARD = """\
226
+ မြန်မာ subtitle ာပြန်ပညရှင်general / family-safe content။
 
227
 
228
+ ဇာတ်ကောင် voice ကို ထုတ်ပေး — AI voice မဟုတ်:
229
+ • ယောက်ျးကြမ / villain → ငါ/မင်း + ကွ/ဗျ/ကွာ (family-safe rangeွင)
 
 
 
 
 
 
 
230
  ��� မိန်းကလေး → ကျမ/ငါ + ကွာ/ဟေ့
231
+ • Elder / boss / formal → ကျွန်တော်/ကျွန်မ
232
+ Comic / light → ပြောပြောဆိုဆို colloquial
233
+ ဆဲစကား / ကြမ်း → source ၏ intensity ကို ထိန်းသိမ်းပြီး family-safe မြန်မာ equivalent သုံးပါ\
 
 
 
 
 
 
 
 
 
 
 
234
  """
235
 
236
+ _STYLE_ADULT = """\
237
+ မြနမာ subtitle ဘာသာပြန်ပညာရှင် — mature / 18+ content
238
+
239
+ ဇာတ်ကောvoice ကို ထုတပေ — AI voice ဟုတ:
240
+ • ယောက်ျားကြမ်း / villain / ဂိုဏ်း → ငါ/မင်း/ကောင် + ကွ/ဗျ/ကွာ
241
+ မိန်းကလေး ရင်းနှီး → ကျမ/ငါ/နင် + ကွာ/ဟေ့
242
+ Boss / formal → ကျွန်တော် (ပြင်ထန်) ို့မဟငါ (dominant)
243
+ • Comic / light → ပြောပြောိုို colloquial
244
+ Strong language — source ၏ exact weight ကို ထိန်းသိမ်း:
245
+ English source → English ထား (Fuck / Shit / Bitch / Bastard / Asshole)
246
+ Other lang source nearest English equivalent ထား\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  """
248
 
249
+ _STYLE_ANIME = """\
250
+ မြနမာ subtitle ဘာသာပြန်ပညာရှင် — Japanese anime / drama / manga।
251
+
252
+ ဇာတ်ကောင် vocal style ကို ထိန်းသိမး:
253
+ • Energetic / shonen → ငါ/မင်း + ကွ/ဗျ colloquial
254
+ Tsundere → တည်ငြိမ်ပြီး ဒေါသကျ, ပြတ်သား
255
+ Kuudere / cool တိုရှင်း ပြတ်သား
256
+ Cute / moe ကျ+ နူညံ့
257
+ Elder / senseiကျွန်တေ်/ရှင် formal
258
+ Strong language → English ထား (Fuck / Shit / Bitch)\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  """
260
 
261
+ _STYLE_CDRAMA = """\
262
+ မြနမာ subtitle ဘာသာပြန်ပညာရှင် — Chinese drama / wuxia / xianxia / movie
263
+
264
+ Tone formal yet emotional, dramatic pacing ကို ထိန်းသိမး:
265
+ • Emperor / high noble → ကျွန်တော်/ကျွန်မ dignified formal
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  • Common folk → သာမန် colloquial
267
+ • Villain / schemer → ကြမ်းတမ်း ပြတ်သား
268
+ • Romantic / poetic lines weight ကို မပျောက်စေ — nearest မြ်မာ emotional equivalent\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  """
270
 
271
+ _STYLE_KDRAMA = """\
272
+ မြနမာ subtitle ဘာသာပြန်ပညာရှင် — Korean drama / movie / webtoon adaptation
273
+
274
+ Tone emotional intensity, sincerity ကို ထိန်ိမ���း:
275
+ • Chaebol / CEO → formal, measured, restrained
276
+ Young adult → modern colloquial — ငါ/ကျမ + ကွာ/ဟေ့/ဗျ
277
+ Elder / parent authoritative + caring register
278
+ Romantic moments emotional weight ပျောကအောင်
279
+ Strong language → English ထား\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  """
281
 
282
+ _STYLE_FORMAL = """\
283
+ မြနမာ subtitle ဘာသာပြန်ပညာရှင် — documentary / news / educational narration
284
+
285
+ Register — objective, formal, educated standard Myanmar:
286
+ • Narration → ပညာတတ် standard register (ပြောပြောဆိုဆို colloquial မသုံးရ)
287
+ Expert quotes → semi-formal educated
288
+ Technical terms precise Myanmar equivalent; မရှှင် (English term) ပြငပကွင်း
289
+ Numbers / dates / statistics → exact\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  """
291
 
292
+ # ── Layer 2: TERMS blocks (culture-specific special terms) ────────────────────
293
+ # Only stated here never repeated in preset STYLE or NOUNS layer.
294
 
295
+ _TERMS_WESTERN = "" # no special terms needed
296
 
297
+ _TERMS_JAPANESE = """\
298
+ Japanese special terms ဤ rule တွေသည် noun style ကို override မလုပ် — term handling သာ:
299
+ Honorifics (-san / -kun / -chan / -senpai / -sensei / -sama / -dono / -nii / -nee) as-is ို့မဟုတ် natural မြန်(Glossary ပါလျှင Glossary)
300
+ Anime / otaku terms (baka, kawaii, nakama, sugoi, yare yare etc.) → English as-is ထား
301
+ Game / isekai system terms (HP, MP, Level, Skill, Quest, Guild, Status) → English as-is
302
+ Cultural terms (onsen, matsuri, bento, senpai-kouhai) → English / Romaji as-is\
 
303
  """
304
 
305
+ _TERMS_CHINESE = """\
306
+ Chinese special terms ဤ rule တွေသည် noun style ကို override မလုပ် — term handling သာ:
307
+ Relationship / title terms Pinyin as-is ထား:
308
+ Shifu, Shidi/Shixiong/Shijie, Gege/Jiejie/Meimei/Didi, A'niang/Niang, Wangye, Gongzi, Guniang
309
+ Wuxia / Xianxia terms English / Pinyin:
310
+ Golden Core, Nascent Soul, cultivation, qi, meridians, sect, immortal, spiritual root
311
+ Historical titles → English: Emperor, Empress, Crown Prince, Noble Consort, Imperial Guard\
312
  """
313
 
314
+ _TERMS_KOREAN = """\
315
+ Korean special terms ဤ rule တွေသည် noun style ကို override မလုပ် — term handling သာ:
316
+ Relationship / honorifics Romanized as-is ထား:
317
+ Oppa, Unnie, Hyung, Noona, Sunbae, Hoobae, Sajangnim, Seonsaengnim
318
+ • Speech level — Korean 존댓말 → formal မြန်မာ | 반말 colloquial မြန်မာ
319
+ Cultural terms Romanized as-is: Ramyeon, Tteokbokki, Hanbok, Jjimjilbang, Aegyo\
 
320
  """
321
 
322
+ _TERMS_THAI = """\
323
+ Thai / SE Asian special terms — ဤ rule တွေသည် noun style ကို override မလုပ် — term handling သာ:
324
+ Honorifics (Khun, Phi, Nong) Romanized as-is သို့ဟုတ် natural မြန်equivalent
325
+ Cultural termsRomanized as-is: Wai, Songkran, Muay Thai, Tuk-tuk\
 
 
 
326
  """
327
 
328
+ _TERMS_UNIVERSAL = "" # mixed/unknown
329
+
330
+ # ── Layer 3: NOUNS block (generated from noun_style × culture) ────────────────
331
+ # Generated once by _noun_block() — never appears in STYLE or TERMS.
332
+
333
+ def _noun_block(style: str, culture_key: str) -> str:
334
+ """Single source of truth for proper noun handling rule."""
335
+ script = {
336
+ "japanese": "Romaji",
337
+ "chinese": "Pinyin",
338
+ "korean": "Romanized Korean",
339
+ "thai": "Romanized Thai",
340
+ "western": "English",
341
+ "universal": "romanized",
342
+ }.get(culture_key, "romanized")
343
+
344
+ examples = {
345
+ "western": [("Victor","ဗစ်တာ"), ("Hope Street","ဟုတ်ပ်စထရိတ်"), ("London","လန်ဒန်")],
346
+ "japanese": [("Sasuke","ဆဆူကေ"), ("Tokyo","တိုကျို"), ("Konoha","ကိုနိုဟာ")],
347
+ "chinese": [("Wei Wuxian","ဝေဝူရှျား"), ("Beijing","ပေကျင်း"), ("Yunmeng","ယွန်မိန်")],
348
+ "korean": [("Park Seo-jun","ပါ့ဆေဂျွန်"), ("Seoul","ဆိုးလ်"), ("Busan","ပူဆမ်")],
349
+ "thai": [("Prayuth","ပြာရတ်"), ("Chiang Mai","ချင်းမိုင်"), ("Bangkok","ဘန်ကောက်")],
350
+ "universal": [("Victor","ဗစ်တာ"), ("Sakura","ဆာကူရာ"), ("Madison","မတ်ဒစ်ဆင်")],
351
+ }.get(culture_key, [("Victor","ဗစ်တာ"), ("Hope Street","ဟုတ်ပ်စထရိတ်"), ("London","လန်ဒန်")])
352
+
353
+ if style == "phonetic":
354
+ ex_lines = "\n".join(f' {e} → {p}' for e, p in examples)
355
+ return (
356
+ f"PROPER NOUNS — Myanmar Phonetic:\n"
357
+ f"နာမည် / နေရာ / အဖွဲ့ → မြန်မာ အသံထွက် transliteration (အဓိပ္ပာယ် မဘာသာမပြန်ရ)\n"
358
+ f"{ex_lines}\n"
359
+ f"Glossary ပါ → Glossary အတိုင်း | မပါ → phonetic"
360
+ )
361
+ else:
362
+ ex_lines = "\n".join(f' "{e}" → "{e}" ✗ not "{p}"' for e, p in examples)
363
+ return (
364
+ f"PROPER NOUNS — {script} spelling:\n"
365
+ f"နာမည် / နေရာ / အဖွဲ့ → {script} မူရင်း spelling (မပြောင်းရ၊ မဘာသာမပြန်ရ)\n"
366
+ f"{ex_lines}\n"
367
+ f"Glossary ပါ → Glossary အတိုင်း | မပါ → {script} မူရင်း"
368
+ )
369
+
370
+ # ── Layer 4: TECH block (always identical) ────────────────────────────────────
371
 
372
+ _TECH = """\
373
+ RULES (non-negotiable):
374
+ 1. Source မပါသောအရာ မဖြည့်ရ — source ပါသောအရာ မနုတ်ရ
375
+ 2. မြန်မာ speaker သဘာဝ word order ကို သုံး — source language structure ကို copy မကူးရ
376
+ 3. Same character = same pronoun + speech style တစ်သားတည်း
377
+ 4. ASS tags ({\\an8} / {\\pos} / {\\be5} / {\\fad} etc.) + ♪ + ⏎ → as-is ထား
378
+ 5. Glossary term → Glossary ထဲက value ကိုသာ သုံးရမည်
379
 
380
+ COUNT: Input N items output EXACTLY N items. Merge / split ห้าม။
381
+ ❌ "ဒါသည် ကောင်းမွန်သောရလဒ်တစ်ခုဖြစ်သည်" ✅ "ဒါကတော့ ကောင်းတဲ့ outcome ပဲ"
382
+ ❌ "သင်သည် ဤနေရာတွင် ဘာကြောင့်ရှိနေသနည်း" ✅ "မင်း ဒီမှာ ဘာလာလုပ်တာလဲ"
383
+ ❌ "ကူညီပေးပါ၊ ကျေးဇူးပြု၍" (source: "Help!") ✅ "ကူညီပါ"
384
+
385
+ Output: JSON array only, EXACTLY n items. No markdown, no explanation.
386
+ ["ဘာသာပြန် ၁", "ဘာသာပြန် ၂", ..., "ဘာသာပြန် n"]\
387
+ """
388
+
389
+ # ── Registry ──────────────────────────────────────────────────────────────────
390
 
391
  PROMPT_PRESETS: dict = {
392
+ "standard": {"label": "🎬 Standard", "desc": "General / family-safe content", "style": _STYLE_STANDARD},
393
+ "adult_18": {"label": "🔞 18+ Adult", "desc": "Mature content — strong language in English", "style": _STYLE_ADULT},
394
+ "anime": {"label": "⛩ Anime / J-Drama", "desc": "Japanese anime, manga, light novels", "style": _STYLE_ANIME},
395
+ "cdrama": {"label": "🏮 C-Drama / Movie", "desc": "Chinese drama, wuxia, xianxia", "style": _STYLE_CDRAMA},
396
+ "kdrama": {"label": "🌸 K-Drama / Movie", "desc": "Korean drama, webtoon, Korean movies", "style": _STYLE_KDRAMA},
397
+ "formal": {"label": "📰 Documentary / Formal","desc": "News, documentary, educational narration", "style": _STYLE_FORMAL},
398
+ "custom": {"label": "✏️ Custom", "desc": "ကိုယ်တိုင် system prompt ရေးထည့်ရတာ", "style": ""},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
400
 
401
  SOURCE_CULTURES: dict = {
402
+ "western": {"label": "🌍 Western", "desc": "English/European productions", "terms": _TERMS_WESTERN},
403
+ "japanese": {"label": "🇯🇵 Japanese", "desc": "Anime, J-Drama, Japanese movies", "terms": _TERMS_JAPANESE},
404
+ "chinese": {"label": "🇨🇳 Chinese", "desc": "C-Drama, Chinese movies, Donghua", "terms": _TERMS_CHINESE},
405
+ "korean": {"label": "🇰🇷 Korean", "desc": "K-Drama, Korean movies", "terms": _TERMS_KOREAN},
406
+ "thai": {"label": "🇹🇭 Thai / SE Asian", "desc": "Thai drama, SE Asian content", "terms": _TERMS_THAI},
407
+ "universal": {"label": "🌐 Unknown / Mixed", "desc": "Multi-cultural or unknown origin", "terms": _TERMS_UNIVERSAL},
408
  }
409
 
 
410
  PROPER_NOUN_STYLES: dict = {
411
+ "english": {
412
  "label": "🔤 English / Romanized (မူရင်း spelling)",
413
  "desc": "Victor, Sakura, Hope Street — မြန်မာ phonetic မပြောင်း (default)",
414
  },
 
419
  }
420
 
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  def build_system_prompt(
423
+ preset_key: str = "adult_18",
424
+ culture_key: str = "western",
425
+ custom_text: str = "",
426
+ proper_noun_style: str = "english",
427
  ) -> str:
428
  """
429
+ Assemble final system prompt from 4 non-overlapping layers:
430
+ STYLE TERMS NOUNS TECH
431
+ Each rule appears exactly once. No redundancy.
432
  """
 
 
 
433
  if preset_key == "custom":
434
+ # Custom: user writes the full prompt; only TECH appended
435
+ body = custom_text.strip() or PROMPT_PRESETS["adult_18"]["style"]
436
+ return body + "\n\n" + _TECH
437
+
438
+ style = PROMPT_PRESETS.get(preset_key, PROMPT_PRESETS["adult_18"])["style"]
439
+ terms = SOURCE_CULTURES.get(culture_key, SOURCE_CULTURES["western"])["terms"]
440
+ nouns = _noun_block(proper_noun_style, culture_key)
441
+
442
+ parts = [style]
443
+ if terms:
444
+ parts.append(terms)
445
+ parts.append(nouns)
446
+ parts.append(_TECH)
 
 
 
 
 
 
 
447
  return "\n\n".join(parts)
448
 
449
 
450
  def _sys_glossary_for_culture(
451
+ culture_key: str = "western",
452
  proper_noun_style: str = "english",
453
  ) -> str:
454
+ """Culture + noun-style aware glossary extraction prompt."""
455
+ noun_rule = _noun_block(proper_noun_style, culture_key)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  return (
457
+ "Extract a Myanmar subtitle translation glossary.\n"
458
+ "Include: character names, place names, organization names, "
459
+ "recurring special terms / slang.\n\n"
460
+ + noun_rule + "\n\n"
461
+ "For recurring special terms / slang: Myanmar မြန်မာ translation as value.\n"
462
+ 'Return ONLY JSON: {"source term": "value"}'
463
  )
464
 
465