cc-switch-tui 0.1.4

All-in-One Assistant for Claude Code, Codex, Gemini, OpenCode, OpenClaw & Hermes
Documentation
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
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
use super::is_chinese;

// ============================================
// ENTITY TYPE CONSTANTS (实体类型常量)
// ============================================

pub fn entity_provider() -> &'static str {
    if is_chinese() {
        "供应商"
    } else {
        "provider"
    }
}

pub fn entity_server() -> &'static str {
    if is_chinese() {
        "服务器"
    } else {
        "server"
    }
}

pub fn entity_prompt() -> &'static str {
    if is_chinese() {
        "提示词"
    } else {
        "prompt"
    }
}

// ============================================
// GENERIC ENTITY OPERATIONS (通用实体操作)
// ============================================

pub fn entity_added_success(entity_type: &str, name: &str) -> String {
    if is_chinese() {
        format!("✓ 成功添加{} '{}'", entity_type, name)
    } else {
        format!("✓ Successfully added {} '{}'", entity_type, name)
    }
}

pub fn entity_updated_success(entity_type: &str, name: &str) -> String {
    if is_chinese() {
        format!("✓ 成功更新{} '{}'", entity_type, name)
    } else {
        format!("✓ Successfully updated {} '{}'", entity_type, name)
    }
}

pub fn entity_deleted_success(entity_type: &str, name: &str) -> String {
    if is_chinese() {
        format!("✓ 成功删除{} '{}'", entity_type, name)
    } else {
        format!("✓ Successfully deleted {} '{}'", entity_type, name)
    }
}

pub fn entity_not_found(entity_type: &str, id: &str) -> String {
    if is_chinese() {
        format!("{}不存在: {}", entity_type, id)
    } else {
        format!("{} not found: {}", entity_type, id)
    }
}

pub fn confirm_create_entity(entity_type: &str) -> String {
    if is_chinese() {
        format!("\n确认创建此{}?", entity_type)
    } else {
        format!("\nConfirm create this {}?", entity_type)
    }
}

pub fn confirm_update_entity(entity_type: &str) -> String {
    if is_chinese() {
        format!("\n确认更新此{}?", entity_type)
    } else {
        format!("\nConfirm update this {}?", entity_type)
    }
}

pub fn confirm_delete_entity(entity_type: &str, name: &str) -> String {
    if is_chinese() {
        format!("\n确认删除{} '{}'?", entity_type, name)
    } else {
        format!("\nConfirm delete {} '{}'?", entity_type, name)
    }
}

pub fn select_to_delete_entity(entity_type: &str) -> String {
    if is_chinese() {
        format!("选择要删除的{}:", entity_type)
    } else {
        format!("Select {} to delete:", entity_type)
    }
}

pub fn no_entities_to_delete(entity_type: &str) -> String {
    if is_chinese() {
        format!("没有可删除的{}", entity_type)
    } else {
        format!("No {} available for deletion", entity_type)
    }
}

// ============================================
// COMMON UI ELEMENTS (通用界面元素)
// ============================================

// Welcome & Headers
pub fn welcome_title() -> &'static str {
    if is_chinese() {
        "    🎯 CC-Switch 交互模式"
    } else {
        "    🎯 CC-Switch Interactive Mode"
    }
}

pub fn application() -> &'static str {
    if is_chinese() {
        "应用程序"
    } else {
        "Application"
    }
}

pub fn goodbye() -> &'static str {
    if is_chinese() {
        "👋 再见!"
    } else {
        "👋 Goodbye!"
    }
}

// Main Menu
pub fn main_menu_prompt(app: &str) -> String {
    if is_chinese() {
        format!("请选择操作 (当前: {})", app)
    } else {
        format!("What would you like to do? (Current: {})", app)
    }
}

pub fn interactive_requires_tty() -> &'static str {
    if is_chinese() {
        "交互模式需要在 TTY 终端中运行(请不要通过管道/重定向调用)。"
    } else {
        "Interactive mode requires a TTY (do not run with pipes/redirection)."
    }
}

pub fn interactive_legacy_tui_removed() -> &'static str {
    if is_chinese() {
        "旧版 legacy TUI 已移除,请直接使用当前默认的交互 TUI。"
    } else {
        "The legacy TUI has been removed. Please use the default interactive TUI instead."
    }
}

// Ratatui TUI (new interactive UI)
pub fn tui_app_title() -> &'static str {
    "cc-switch-tui"
}

pub fn tui_tabs_title() -> &'static str {
    if is_chinese() {
        "App"
    } else {
        "App"
    }
}

pub fn tui_hint_app_switch() -> &'static str {
    if is_chinese() {
        "切换 App:"
    } else {
        "Switch App:"
    }
}

pub fn tui_filter_icon() -> &'static str {
    "🔎 "
}

pub fn tui_marker_active() -> &'static str {
    "✓"
}

pub fn tui_marker_inactive() -> &'static str {
    " "
}

pub fn tui_highlight_symbol() -> &'static str {
    "➤ "
}

pub fn tui_toast_prefix_info() -> &'static str {
    " ℹ "
}

pub fn tui_toast_prefix_success() -> &'static str {
    " ✓ "
}

pub fn tui_toast_prefix_warning() -> &'static str {
    " ! "
}

pub fn tui_toast_prefix_error() -> &'static str {
    " ✗ "
}

pub fn tui_toast_invalid_json(details: &str) -> String {
    if is_chinese() {
        format!("JSON 无效:{details}")
    } else {
        format!("Invalid JSON: {details}")
    }
}

pub fn tui_toast_json_must_be_object() -> &'static str {
    if is_chinese() {
        "JSON 必须是对象(例如:{\"env\":{...}})"
    } else {
        "JSON must be an object (e.g. {\"env\":{...}})"
    }
}

pub fn tui_error_invalid_config_structure(e: &str) -> String {
    if is_chinese() {
        format!("配置结构无效:{e}")
    } else {
        format!("Invalid config structure: {e}")
    }
}

pub fn tui_rule(width: usize) -> String {
    if is_chinese() {
        "─".repeat(width)
    } else {
        "─".repeat(width)
    }
}

pub fn tui_rule_heavy(width: usize) -> String {
    if is_chinese() {
        "═".repeat(width)
    } else {
        "═".repeat(width)
    }
}

pub fn tui_icon_app() -> &'static str {
    "📱"
}

pub fn tui_default_config_filename() -> &'static str {
    "config.json"
}

pub fn tui_default_config_export_path() -> &'static str {
    "./config-export.sql"
}

pub fn tui_default_common_snippet() -> &'static str {
    "{}\n"
}

pub fn tui_default_common_snippet_for_app(app: &str) -> &'static str {
    match app {
        "codex" => "",
        _ => "{}\n",
    }
}

pub fn tui_latency_ms(ms: u128) -> String {
    if is_chinese() {
        format!("{ms} ms")
    } else {
        format!("{ms} ms")
    }
}
pub fn tui_nav_title() -> &'static str {
    if is_chinese() {
        "菜单"
    } else {
        "Menu"
    }
}

pub fn tui_filter_title() -> &'static str {
    if is_chinese() {
        "过滤"
    } else {
        "Filter"
    }
}

pub fn tui_footer_global() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  ←→ 切换菜单/内容  ↑↓ 移动  Enter 详情  s 切换  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  ←→ focus menu/content  ↑↓ move  Enter details  s switch  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_group_nav() -> &'static str {
    if is_chinese() {
        "导航"
    } else {
        "NAV"
    }
}

pub fn tui_footer_group_actions() -> &'static str {
    if is_chinese() {
        "功能"
    } else {
        "ACT"
    }
}

pub fn tui_footer_nav_keys() -> &'static str {
    if is_chinese() {
        "←→ 菜单/内容  ↑↓ 移动"
    } else {
        "←→ menu/content  ↑↓ move"
    }
}

pub fn tui_footer_action_keys() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Enter 详情  s 切换  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Enter details  s switch  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_main() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_providers() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Enter 详情  Space 切换  a 新增  e 编辑  d 删除  t 测试  r 刷新  o 临时启动  f 管理故障转移  x 设为默认  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Enter details  Space switch  a add  e edit  d delete  t test  r refresh  o launch temp  f manage failover  x set default  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_provider_detail() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Space 切换  e 编辑  t 测试  r 刷新  o 临时启动  f 管理故障转移  x 设为默认  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Space switch  e edit  t test  r refresh  o launch temp  f manage failover  x set default  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_mcp() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  x 启用/禁用  m 应用  a 添加  e 编辑  i 导入  d 删除  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  x toggle  m apps  a add  e edit  i import  d delete  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_prompts() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Enter 查看  a 激活  x 取消激活  e 编辑  d 删除  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Enter view  a activate  x deactivate  e edit  d delete  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_config() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Enter 打开  e 编辑片段  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Enter open  e edit snippet  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_common_snippet_view() -> &'static str {
    if is_chinese() {
        "a 应用  c 清空  e 编辑  ↑↓ 滚动  Esc 返回"
    } else {
        "a apply  c clear  e edit  ↑↓ scroll  Esc back"
    }
}

pub fn tui_footer_action_keys_settings() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  Enter 应用  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  Enter apply  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_action_keys_global() -> &'static str {
    if is_chinese() {
        "[ ] 切换应用  / 过滤  Esc 返回  ? 帮助"
    } else {
        "[ ] switch app  / filter  Esc back  ? help"
    }
}

pub fn tui_footer_filter_mode() -> &'static str {
    if is_chinese() {
        "输入关键字过滤,Enter 应用,Esc 清空并退出"
    } else {
        "Type to filter, Enter apply, Esc clear & exit"
    }
}

pub fn tui_help_title() -> &'static str {
    if is_chinese() {
        "帮助"
    } else {
        "Help"
    }
}

pub fn tui_help_text() -> &'static str {
    if is_chinese() {
        "[ ]  切换应用\n←→  切换菜单/内容焦点\n↑↓  移动\n/   过滤\nEsc  返回\n?   显示/关闭帮助\n\n文本输入:Ctrl+A/E 行首/行尾,Ctrl+U/K 删除行片段,Ctrl+W 删除前词,Alt+B/F 按词移动\n\n页面快捷键(在页面内容区顶部显示):\n- 供应商:Enter 详情,Space 切换,a 新增,e 编辑,d 删除,t 测试,r 刷新,o 临时启动,f 管理故障转移,x 设为默认\n- 供应商详情:Space 切换,e 编辑,t 测试,r 刷新,o 临时启动,f 管理故障转移,x 设为默认\n- MCP:x 启用/禁用(当前应用),m 选择应用,a 添加,e 编辑,i 导入已有,d 删除\n- 提示词:c 新建,r 刷新,Enter 查看,a 激活,x 取消激活(当前),n 重命名,e 编辑,d 删除\n- 技能:Enter 详情,x 启用/禁用(当前应用),m 选择应用,d 卸载,i 导入已有\n- 配置:Enter 打开/执行,e 编辑片段\n- 设置:Enter 应用"
    } else {
        "[ ]  switch app\n←→  focus menu/content\n↑↓  move\n/   filter\nEsc  back\n?   toggle help\n\nText input: Ctrl+A/E move line, Ctrl+U/K delete line parts, Ctrl+W delete word, Alt+B/F move word\n\nPage keys (shown at the top of each page):\n- Providers: Enter details, Space switch, a add, e edit, d delete, t test, r refresh, o launch temp, f manage failover, x set default\n- Provider Detail: Space switch, e edit, t test, r refresh, o launch temp, f manage failover, x set default\n- MCP: x toggle current, m select apps, a add, e edit, i import existing, d delete\n- Prompts: c create, r refresh, Enter view, a activate, x deactivate active, n rename, e edit, d delete\n- Skills: Enter details, x toggle current, m select apps, d uninstall, i import existing\n- Config: Enter open/run, e edit snippet\n- Settings: Enter apply"
    }
}

pub fn tui_confirm_title() -> &'static str {
    if is_chinese() {
        "确认"
    } else {
        "Confirm"
    }
}

pub fn tui_confirm_exit_title() -> &'static str {
    if is_chinese() {
        "退出"
    } else {
        "Exit"
    }
}

pub fn tui_confirm_exit_message() -> &'static str {
    if is_chinese() {
        "确定退出 cc-switch?"
    } else {
        "Exit cc-switch?"
    }
}

pub fn tui_confirm_yes_hint() -> &'static str {
    if is_chinese() {
        "y/Enter = 是"
    } else {
        "y/Enter = Yes"
    }
}

pub fn tui_confirm_no_hint() -> &'static str {
    if is_chinese() {
        "n/Esc   = 否"
    } else {
        "n/Esc   = No"
    }
}

pub fn tui_input_title() -> &'static str {
    if is_chinese() {
        "输入"
    } else {
        "Input"
    }
}

pub fn tui_editor_text_field_title() -> &'static str {
    if is_chinese() {
        "文本"
    } else {
        "Text"
    }
}

pub fn tui_editor_json_field_title() -> &'static str {
    "JSON"
}

pub fn tui_editor_hint_view() -> &'static str {
    if is_chinese() {
        "Enter 编辑  ↑↓ 滚动  Ctrl+S 保存  Esc 返回"
    } else {
        "Enter edit  ↑↓ scroll  Ctrl+S save  Esc back"
    }
}

pub fn tui_editor_hint_edit() -> &'static str {
    if is_chinese() {
        "编辑中:Esc 退出编辑  Ctrl+S 保存"
    } else {
        "Editing: Esc stop editing  Ctrl+S save"
    }
}

pub fn tui_editor_discard_title() -> &'static str {
    if is_chinese() {
        "放弃修改"
    } else {
        "Discard Changes"
    }
}

pub fn tui_editor_discard_message() -> &'static str {
    if is_chinese() {
        "有未保存的修改,确定放弃?"
    } else {
        "You have unsaved changes. Discard them?"
    }
}

pub fn tui_editor_save_before_close_title() -> &'static str {
    if is_chinese() {
        "当前未保存"
    } else {
        "Unsaved Changes"
    }
}

pub fn tui_editor_save_before_close_message() -> &'static str {
    if is_chinese() {
        "当前有未保存的修改。"
    } else {
        "You have unsaved changes."
    }
}

pub fn tui_speedtest_title() -> &'static str {
    if is_chinese() {
        "测速"
    } else {
        "Speedtest"
    }
}

pub fn tui_stream_check_title() -> &'static str {
    if is_chinese() {
        "健康检查"
    } else {
        "Stream Check"
    }
}

pub fn tui_provider_test_menu_title() -> &'static str {
    if is_chinese() {
        "测试"
    } else {
        "Test"
    }
}

pub fn tui_main_hint() -> &'static str {
    if is_chinese() {
        "使用左侧菜单(↑↓ + Enter)。←→ 在菜单与内容间切换焦点。"
    } else {
        "Use the left menu (↑↓ + Enter). ←→ switches focus between menu and content."
    }
}

pub fn tui_header_proxy_status(enabled: bool) -> String {
    if is_chinese() {
        format!("代理: {}", if enabled { "开" } else { "关" })
    } else {
        format!("Proxy: {}", if enabled { "On" } else { "Off" })
    }
}

pub fn tui_home_section_connection() -> &'static str {
    if is_chinese() {
        "连接信息"
    } else {
        "Connection Details"
    }
}

pub fn tui_home_section_proxy() -> &'static str {
    if is_chinese() {
        "代理仪表盘"
    } else {
        "Proxy Dashboard"
    }
}

pub fn tui_home_section_context() -> &'static str {
    if is_chinese() {
        "Session Context"
    } else {
        "Session Context"
    }
}

pub fn tui_home_section_local_env_check() -> &'static str {
    if is_chinese() {
        "本地环境检查"
    } else {
        "Local environment check"
    }
}

pub fn tui_home_section_webdav() -> &'static str {
    if is_chinese() {
        "WebDAV 同步"
    } else {
        "WebDAV Sync"
    }
}

pub fn tui_label_webdav_status() -> &'static str {
    if is_chinese() {
        "状态"
    } else {
        "Status"
    }
}

pub fn tui_label_webdav_last_sync() -> &'static str {
    if is_chinese() {
        "最近同步"
    } else {
        "Last sync"
    }
}

pub fn tui_webdav_status_not_configured() -> &'static str {
    if is_chinese() {
        "未配置"
    } else {
        "Not configured"
    }
}

pub fn tui_webdav_status_configured() -> &'static str {
    if is_chinese() {
        "已配置"
    } else {
        "Configured"
    }
}

pub fn tui_webdav_status_never_synced() -> &'static str {
    if is_chinese() {
        "从未同步"
    } else {
        "Never synced"
    }
}

pub fn tui_webdav_status_ok() -> &'static str {
    if is_chinese() {
        "正常"
    } else {
        "OK"
    }
}

pub fn tui_webdav_status_error() -> &'static str {
    if is_chinese() {
        "失败"
    } else {
        "Error"
    }
}

pub fn tui_webdav_status_error_with_detail(detail: &str) -> String {
    if is_chinese() {
        format!("失败({detail})")
    } else {
        format!("Error ({detail})")
    }
}

pub fn tui_local_env_not_installed() -> &'static str {
    if is_chinese() {
        "未安装或不可执行"
    } else {
        "not installed or not executable"
    }
}

pub fn tui_home_status_online() -> &'static str {
    if is_chinese() {
        "在线"
    } else {
        "Online"
    }
}

pub fn tui_home_status_offline() -> &'static str {
    if is_chinese() {
        "离线"
    } else {
        "Offline"
    }
}

pub fn tui_proxy_dashboard_status_running() -> &'static str {
    if is_chinese() {
        "已启用"
    } else {
        "ACTIVE"
    }
}

pub fn tui_proxy_dashboard_status_stopped() -> &'static str {
    if is_chinese() {
        "本地"
    } else {
        "LOCAL"
    }
}

pub fn tui_proxy_dashboard_status_local_only() -> &'static str {
    if is_chinese() {
        "仅本地"
    } else {
        "LOCAL ONLY"
    }
}

pub fn tui_proxy_dashboard_status_unsupported() -> &'static str {
    if is_chinese() {
        "不支持"
    } else {
        "UNSUPPORTED"
    }
}

pub fn tui_proxy_dashboard_manual_routing_copy(app: &str) -> String {
    if is_chinese() {
        format!("手动路由:{app} 的流量会通过 cc-switch。")
    } else {
        format!("Manual routing only: traffic goes through cc-switch for {app}.")
    }
}

pub fn tui_proxy_dashboard_failover_copy() -> &'static str {
    if is_chinese() {
        "仅做手动路由,不会自动切换供应商。"
    } else {
        "automatic failover stays off; provider changes stay manual."
    }
}

pub fn tui_proxy_dashboard_cta_start(app: &str) -> String {
    if is_chinese() {
        format!("按 P 启动托管代理,并让 {app} 走 cc-switch。")
    } else {
        format!("Press P to start the managed proxy and route {app} through cc-switch.")
    }
}

pub fn tui_proxy_dashboard_cta_stop(app: &str) -> String {
    if is_chinese() {
        format!("按 P 恢复 {app} 的 live 配置,并停止托管代理。")
    } else {
        format!("Press P to restore {app} to its live config and stop the managed proxy.")
    }
}

pub fn tui_proxy_loading_title_start() -> &'static str {
    if is_chinese() {
        "启动代理中"
    } else {
        "Starting proxy"
    }
}

pub fn tui_proxy_loading_title_stop() -> &'static str {
    if is_chinese() {
        "停止代理中"
    } else {
        "Stopping proxy"
    }
}

pub fn tui_proxy_dashboard_running_elsewhere() -> &'static str {
    if is_chinese() {
        "代理已在运行。请先停止当前路由,再从这里启动。"
    } else {
        "Proxy is already running. Stop the current route before starting it here."
    }
}

pub fn tui_proxy_dashboard_current_app_on(app: &str) -> String {
    if is_chinese() {
        format!("{app} 已接入代理")
    } else {
        format!("{app} active")
    }
}

pub fn tui_proxy_dashboard_current_app_off(app: &str) -> String {
    if is_chinese() {
        format!("{app} 本地直连")
    } else {
        format!("{app} local")
    }
}

pub fn tui_proxy_dashboard_unsupported_app(app: &str) -> String {
    if is_chinese() {
        format!("{app} 仅本地")
    } else {
        format!("{app} local only")
    }
}

pub fn tui_proxy_dashboard_shared_runtime_ready() -> &'static str {
    if is_chinese() {
        "共享 runtime 就绪"
    } else {
        "Shared runtime ready"
    }
}

pub fn tui_proxy_dashboard_no_route_for_app(app: &str) -> String {
    if is_chinese() {
        format!("{app} 暂无路由")
    } else {
        format!("No route for {app} yet")
    }
}

pub fn tui_proxy_dashboard_takeover_active() -> &'static str {
    if is_chinese() {
        "已接管"
    } else {
        "active"
    }
}

pub fn tui_proxy_dashboard_takeover_inactive() -> &'static str {
    if is_chinese() {
        "未接管"
    } else {
        "inactive"
    }
}

pub fn tui_proxy_dashboard_takeover_unsupported() -> &'static str {
    if is_chinese() {
        "不支持"
    } else {
        "not supported"
    }
}

pub fn tui_proxy_dashboard_uptime_stopped() -> &'static str {
    if is_chinese() {
        "未运行"
    } else {
        "--"
    }
}

pub fn tui_proxy_dashboard_requests_idle() -> &'static str {
    if is_chinese() {
        "暂无流量"
    } else {
        "No traffic yet"
    }
}

pub fn tui_proxy_dashboard_tokens_idle() -> &'static str {
    if is_chinese() {
        "暂无 token 流量"
    } else {
        "No token traffic yet"
    }
}

pub fn tui_proxy_dashboard_target_waiting() -> &'static str {
    if is_chinese() {
        "等待首个请求"
    } else {
        "Waiting for first request"
    }
}

pub fn tui_proxy_dashboard_request_summary(total: u64, success_rate: f32) -> String {
    if is_chinese() {
        format!("{total} 总计 / {success_rate:.1}% 成功")
    } else {
        format!("{total} total / {success_rate:.1}% success")
    }
}

pub fn tui_proxy_dashboard_token_summary(output: &str, input: &str) -> String {
    if is_chinese() {
        format!("{output} 下行 / {input} 上行")
    } else {
        format!("{output} out / {input} in")
    }
}

pub fn tui_label_current_app_takeover() -> &'static str {
    if is_chinese() {
        "当前应用接管"
    } else {
        "Current app takeover"
    }
}

pub fn tui_label_current_app_route() -> &'static str {
    if is_chinese() {
        "当前应用路由"
    } else {
        "Current app route"
    }
}

pub fn tui_label_latest_proxy_route() -> &'static str {
    if is_chinese() {
        "最近代理路由"
    } else {
        "Latest proxy route"
    }
}

pub fn tui_label_shared_runtime() -> &'static str {
    if is_chinese() {
        "共享 runtime"
    } else {
        "Shared runtime"
    }
}

pub fn tui_label_listen() -> &'static str {
    if is_chinese() {
        "监听"
    } else {
        "Listen"
    }
}

pub fn tui_label_uptime() -> &'static str {
    if is_chinese() {
        "运行时长"
    } else {
        "Uptime"
    }
}

pub fn tui_label_requests() -> &'static str {
    if is_chinese() {
        "请求"
    } else {
        "Requests"
    }
}

pub fn tui_label_traffic() -> &'static str {
    if is_chinese() {
        "流量"
    } else {
        "Traffic"
    }
}

pub fn tui_label_proxy_requests() -> &'static str {
    if is_chinese() {
        "代理总请求"
    } else {
        "Proxy requests"
    }
}

pub fn tui_label_active_target() -> &'static str {
    if is_chinese() {
        "当前路由目标"
    } else {
        "Active target"
    }
}

pub fn tui_label_last_error() -> &'static str {
    if is_chinese() {
        "最近错误"
    } else {
        "Last error"
    }
}

pub fn tui_label_last_proxy_error() -> &'static str {
    if is_chinese() {
        "最近一次代理错误"
    } else {
        "Last proxy error"
    }
}

pub fn tui_label_mcp_servers_active() -> &'static str {
    if is_chinese() {
        "已启用"
    } else {
        "Active"
    }
}

pub fn tui_na() -> &'static str {
    "N/A"
}

pub fn tui_loading() -> &'static str {
    if is_chinese() {
        "处理中…"
    } else {
        "Working…"
    }
}

pub fn tui_header_quota() -> &'static str {
    if is_chinese() {
        "额度"
    } else {
        "Quota"
    }
}

pub fn tui_label_quota() -> &'static str {
    if is_chinese() {
        "额度"
    } else {
        "Quota"
    }
}

pub fn tui_quota_loading() -> &'static str {
    if is_chinese() {
        "查询中…"
    } else {
        "checking…"
    }
}

pub fn tui_quota_not_available() -> &'static str {
    if is_chinese() {
        "不可用"
    } else {
        "not available"
    }
}

pub fn tui_quota_parse_error() -> &'static str {
    if is_chinese() {
        "凭据解析失败"
    } else {
        "credential parse failed"
    }
}

pub fn tui_quota_expired() -> &'static str {
    if is_chinese() {
        "登录过期"
    } else {
        "login expired"
    }
}

pub fn tui_quota_query_failed() -> &'static str {
    if is_chinese() {
        "查询失败"
    } else {
        "query failed"
    }
}

pub fn tui_quota_not_queried() -> &'static str {
    if is_chinese() {
        "未查询"
    } else {
        "not queried"
    }
}

pub fn tui_quota_refresh_hint() -> &'static str {
    if is_chinese() {
        "按 r 刷新"
    } else {
        "press r to refresh"
    }
}

pub fn tui_quota_ok() -> &'static str {
    if is_chinese() {
        "已获取"
    } else {
        "ok"
    }
}

pub fn tui_quota_last_checked() -> &'static str {
    if is_chinese() {
        "更新于"
    } else {
        "checked"
    }
}

pub fn tui_quota_resets_in(time: &str) -> String {
    if is_chinese() {
        format!("{time} 后重置")
    } else {
        format!("resets in {time}")
    }
}

pub fn tui_quota_just_now() -> &'static str {
    if is_chinese() {
        "刚刚"
    } else {
        "just now"
    }
}

pub fn tui_quota_minutes_ago(count: i64) -> String {
    if is_chinese() {
        format!("{count} 分钟前")
    } else if count == 1 {
        "1 minute ago".to_string()
    } else {
        format!("{count} minutes ago")
    }
}

pub fn tui_quota_hours_ago(count: i64) -> String {
    if is_chinese() {
        format!("{count} 小时前")
    } else if count == 1 {
        "1 hour ago".to_string()
    } else {
        format!("{count} hours ago")
    }
}

pub fn tui_quota_days_ago(count: i64) -> String {
    if is_chinese() {
        format!("{count} 天前")
    } else if count == 1 {
        "1 day ago".to_string()
    } else {
        format!("{count} days ago")
    }
}

pub fn tui_quota_extra_usage() -> &'static str {
    if is_chinese() {
        "额外用量"
    } else {
        "Extra usage"
    }
}

pub fn tui_quota_tier_five_hour() -> &'static str {
    if is_chinese() {
        "5小时"
    } else {
        "5h"
    }
}

pub fn tui_quota_tier_seven_day() -> &'static str {
    if is_chinese() {
        "7天"
    } else {
        "7d"
    }
}

pub fn tui_quota_tier_seven_day_opus() -> &'static str {
    if is_chinese() {
        "7天 Opus"
    } else {
        "7d Opus"
    }
}

pub fn tui_quota_tier_seven_day_sonnet() -> &'static str {
    if is_chinese() {
        "7天 Sonnet"
    } else {
        "7d Sonnet"
    }
}

pub fn tui_quota_tier_weekly_limit() -> &'static str {
    if is_chinese() {
        "周额度"
    } else {
        "weekly"
    }
}

pub fn tui_quota_tier_premium() -> &'static str {
    "premium"
}

pub fn tui_quota_tier_gemini_pro() -> &'static str {
    "Gemini Pro"
}

pub fn tui_quota_tier_gemini_flash() -> &'static str {
    "Gemini Flash"
}

pub fn tui_quota_tier_gemini_flash_lite() -> &'static str {
    "Gemini Flash Lite"
}

pub fn tui_header_id() -> &'static str {
    "ID"
}

pub fn tui_header_api_url() -> &'static str {
    "API URL"
}

pub fn tui_header_directory() -> &'static str {
    if is_chinese() {
        "目录"
    } else {
        "Directory"
    }
}

pub fn tui_header_repo() -> &'static str {
    if is_chinese() {
        "仓库"
    } else {
        "Repo"
    }
}

pub fn tui_header_branch() -> &'static str {
    if is_chinese() {
        "分支"
    } else {
        "Branch"
    }
}

pub fn tui_header_path() -> &'static str {
    if is_chinese() {
        "路径"
    } else {
        "Path"
    }
}

pub fn tui_header_found_in() -> &'static str {
    if is_chinese() {
        "发现于"
    } else {
        "Found In"
    }
}

pub fn tui_header_field() -> &'static str {
    if is_chinese() {
        "字段"
    } else {
        "Field"
    }
}

pub fn tui_header_value() -> &'static str {
    if is_chinese() {
        "值"
    } else {
        "Value"
    }
}

pub fn tui_header_claude_short() -> &'static str {
    "C"
}

pub fn tui_header_codex_short() -> &'static str {
    "X"
}

pub fn tui_header_gemini_short() -> &'static str {
    "G"
}

pub fn tui_header_opencode_short() -> &'static str {
    "O"
}

pub fn tui_label_id() -> &'static str {
    "ID"
}

pub fn tui_label_api_url() -> &'static str {
    "API URL"
}

pub fn tui_label_directory() -> &'static str {
    if is_chinese() {
        "目录"
    } else {
        "Directory"
    }
}

pub fn tui_label_enabled_for() -> &'static str {
    if is_chinese() {
        "已启用"
    } else {
        "Enabled"
    }
}

pub fn tui_label_repo() -> &'static str {
    if is_chinese() {
        "仓库"
    } else {
        "Repo"
    }
}

pub fn tui_label_readme() -> &'static str {
    if is_chinese() {
        "README"
    } else {
        "README"
    }
}

pub fn tui_label_base_url() -> &'static str {
    if is_chinese() {
        "API 请求地址"
    } else {
        "Base URL"
    }
}

pub fn tui_label_api_key() -> &'static str {
    if is_chinese() {
        "API Key"
    } else {
        "API Key"
    }
}

pub fn tui_label_claude_api_format() -> &'static str {
    if is_chinese() {
        "API 格式"
    } else {
        "API Format"
    }
}

pub fn tui_claude_api_format_value(api_format: &str) -> &'static str {
    match api_format {
        "openai_chat" => {
            if is_chinese() {
                "OpenAI Chat Completions (需开启代理)"
            } else {
                "OpenAI Chat Completions (Requires proxy)"
            }
        }
        "openai_responses" => {
            if is_chinese() {
                "OpenAI Responses API (需开启代理)"
            } else {
                "OpenAI Responses API (Requires proxy)"
            }
        }
        _ => {
            if is_chinese() {
                "Anthropic Messages (原生)"
            } else {
                "Anthropic Messages (Native)"
            }
        }
    }
}

pub fn tui_claude_api_format_requires_proxy_title() -> &'static str {
    if is_chinese() {
        "需开启代理"
    } else {
        "Proxy Required"
    }
}

pub fn tui_claude_api_format_requires_proxy_message(api_format: &str) -> String {
    let label = tui_claude_api_format_value(api_format);
    if is_chinese() {
        format!("已切换为 {label}。\n该格式需开启本地代理使用。\n请在主页按 P 打开本地代理。")
    } else {
        format!("Switched to {label}.\nThis format requires the local proxy.\nPress P on the home page to open local proxy.")
    }
}