konoma 0.28.1

Terminal file browser built for AI pair-programming — full-screen previews (Markdown, images, PDF, CSV), a git suite (jj/Jujutsu in preview), and an agent-watch mode that follows your AI's edits (macOS and Linux)
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
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
// Lightweight internationalization (i18n). Switched via the `ui.lang` setting (default en).
// A "language file" scheme that gathers strings into the enum key `Msg` and per-language tables
// (en()/jp()).
// To add a string: add a variant to `Msg` and add a line to both en()/jp() (exhaustiveness is
// enforced by the compiler).
// To add a language: add a variant to `Lang`, its corresponding table function, and a branch in `tr`.

/// Display language. Selected by the `ui.lang` setting (default en).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Lang {
    En,
    Jp,
}

impl Lang {
    pub fn parse(s: &str) -> Self {
        match s.trim().to_ascii_lowercase().as_str() {
            "jp" | "ja" | "japanese" | "日本語" => Self::Jp,
            _ => Self::En, // default to English
        }
    }

    /// Resolve the `ui.lang` setting. Unspecified-equivalent values (empty / "auto" / "system") follow the **OS default language**,
    /// otherwise the value is treated as an explicit choice and passed to `parse`. When there is no config file, or lang is omitted, "auto" is the default.
    pub fn resolve(s: &str) -> Self {
        match s.trim().to_ascii_lowercase().as_str() {
            "" | "auto" | "system" => Self::from_os(),
            _ => Self::parse(s),
        }
    }

    /// Determine the OS default language. Tests must not depend on the runtime environment's language (always English).
    #[cfg(test)]
    fn from_os() -> Self {
        Self::En
    }

    /// Determine the OS default language via `sys-locale` (no external process: on macOS this links
    /// CoreFoundation directly — `CFLocaleCopyPreferredLanguages`, the same source the former
    /// `defaults read -g AppleLanguages` call read — and on Linux/BSD it reads the locale
    /// environment variables, `LANGUAGE` → `LC_ALL` → `LC_MESSAGES` → `LANG`, which supersedes the
    /// previous hand-rolled `LC_ALL`/`LC_MESSAGES`/`LANG` loop here). English if undeterminable.
    /// The returned tag may use either separator (`ja-JP` BCP-47 from sys-locale, `ja_JP` POSIX-style
    /// from a raw env var) — `from_lang_tag` only checks the leading "ja", so both work unchanged.
    #[cfg(not(test))]
    fn from_os() -> Self {
        match sys_locale::get_locale() {
            Some(tag) => Self::from_lang_tag(&tag),
            None => Self::En,
        }
    }

    /// Jp if the language part of a language tag/locale string is Japanese (starts with "ja"), otherwise En.
    /// Examples: "ja", "ja-JP", "ja_JP.UTF-8" → Jp / "en-US", "en_US.UTF-8", "C", "" → En.
    fn from_lang_tag(s: &str) -> Self {
        if s.trim().to_ascii_lowercase().starts_with("ja") {
            Self::Jp
        } else {
            Self::En
        }
    }
}

/// Keys for display strings. The actual strings live in the per-language tables en()/jp().
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Msg {
    GitNoBranchesItem,
    /// Worktree list's empty-state row (shown when a filter narrows the list to zero rows).
    GitNoWorktreesItem,
    /// `?` help section title for the worktree list.
    GitWorktreesLabel,
    /// Flash on `w` (open the worktree list) when there is nothing to show (not a repo / git off —
    /// a real repository always has at least the main worktree).
    NoWorktrees,
    /// Flash refusing to switch/open into a bare main worktree (no checkout exists there).
    WorktreeIsBare,
    /// Flash refusing to switch/open into a prunable or missing worktree.
    WorktreeUnavailable,
    /// Flash when the selected worktree is already the one this tab is in.
    WorktreeAlreadyCurrent,
    /// Footer/help hint for the worktree list's own keys.
    WorktreesNavHint,
    /// Inner-mode chip label while the worktree list is open.
    StWorktrees,
    /// Persistent chip shown whenever the current root is inside a **linked worktree** (never for
    /// the main working tree). Language-neutral by design (an abbreviation, not a sentence), but
    /// kept as a `Msg` for the usual catalog sweep/consistency.
    StWorktreeChip,
    /// `?` help row label for `Enter` in the worktree list.
    GitWorktreeSwitch,
    /// Changes-hub `?` help row label for `w` (short noun, matching `GitBranches`'s "branches").
    GitWorktreesRow,
    /// `?` help row label for `d` in the worktree list (show the selected worktree's diff).
    WorktreeShowChangesHelp,
    /// `?` help row label for `n` in the worktree list (create a new linked worktree).
    WorktreeCreateHelp,
    /// Input-dialog title for `n` in the worktree list. Asks for a branch name only — new vs.
    /// existing is auto-detected (`git::branch_tip`), no separate prompt for it.
    NewWorktree,
    /// Flash on a successful `n` (prefixed to the created worktree's path).
    CreatedWorktree,
    GitNoChangesItem,
    GitNoCommitsItem,
    BmTitle,
    DlgConfirmTitle,
    DlgDropTitle,
    HelpTitle,
    InfoTitle,
    DlgInputTitle,
    DlgRenamePreviewTitle,
    DlgDeletePermanentHint,
    DlgForceDeleteHint,
    BmEmpty,
    GitNoChanges,
    BatchRename,
    GitCommitWorktreeDetail,
    CommitMessage,
    Committed,
    Copied,
    Create,
    Created,
    CreatedBranch,
    StScrollHintCtrl,
    CutDone,
    DeleteTarget,
    DeleteBranch,
    DeletedBranch,
    DeletedPermanently,
    DiscardChangesTo,
    Discarded,
    StApplyClearHint,
    StCommitHint,
    StCreateHint,
    StRenamePreviewHint,
    StRenameHint,
    StSearchHint,
    TreeFile,
    GitBranchesLabel,
    GitChangesLabel,
    TreeGitChangesHub,
    GitGraphLabel,
    GitLogLabel,
    TreeGitStatus,
    BmGlobal,
    HelpGlobal,
    BmLocal,
    InfoModified,
    Moved,
    MovedToTrash,
    NewBranch,
    Pasted,
    Duplicated,
    InfoPerm,
    PreviewGitDiff,
    PreviewImage,
    PreviewTextMarkdown,
    Rename,
    Renamed,
    TreeSelection,
    InfoSize,
    StPagerSpaceHint,
    Staged,
    StagedAll,
    SwitchedTo,
    HelpTabs,
    InfoTarget,
    TreeSection,
    InfoType,
    UncommittedChanges,
    Unstaged,
    UnstagedAll,
    Highlighting,
    ScrollTop,
    ScrollBot,
    ScrollAll,
    StSortHint,
    StPathAbs,
    TreeAddedStaged,
    AlreadyAtStartDir,
    AlreadyRoot,
    AnchorReset,
    TreeAnchorRoot,
    GitBack,
    BackToGitView,
    BackToChanges,
    BackToTree,
    TreeBookmarkHint,
    PreviewBookmarkHint,
    BookmarkTargetMissing,
    Bookmarked,
    GitBranches,
    DlgCopyKey,
    StCopyMoveHint,
    CantCloseLastTab,
    Canceled,
    CannotDeleteCurrentBranch,
    CannotEditDirectory,
    CannotPasteIntoSelf,
    GitCheckout,
    ClipboardEmpty,
    GitCloseView,
    GitCommit,
    GitCommitDetail,
    CopiedPrefix,
    /// Prefix for "the tree will not auto-refresh because the filesystem watch failed" (path follows).
    WatchFailedPrefix,
    CopyHint,
    CopyFailed,
    CopiedCodeBlock,
    HintCopyCode,
    CutHint,
    CyclePathStyle,
    GitDelete,
    TreeDeleted,
    GitDetail,
    GitDiffAll,
    TreeDiffFile,
    DiffAuto,
    DiffSideBySide,
    DiffUnified,
    InfoDirectory,
    GitDiscardFile,
    DiscardWholeFile,
    TreeDragDrop,
    TreeDropFiles,
    DroppedItems,
    EditExternal,
    EditExternalEnv,
    EditorFailed,
    EnterDirectory,
    Etc,
    ExpandInPlace,
    GitExternalTool,
    Failed,
    InfoFile,
    GitFileDiff,
    TreeFileInfo,
    TreeFilter,
    GitFilterByName,
    FocusMdLink,
    MdTaskToggleHelp,
    HintDetailsToggle,
    GitToolFailed,
    GlobalApp,
    HScroll,
    GitHScrollEnds,
    StCloseHint,
    InfoClose,
    AnchorNotFound,
    OutlineEmpty,
    InvalidMarkKey,
    Items,
    InfoItems,
    VisualOpsHint,
    BranchesNavHint,
    GitNavDetailHint,
    GitNavDetailCommitHint,
    GraphBaseSet,
    GraphBaseCleared,
    GraphBaseNeedsCommit,
    GraphSetBaseHelp,
    GraphClearBaseHelp,
    GraphBranchesHelp,
    GraphLegendHidden,
    GraphPickerTitle,
    GraphPickerFooter,
    GraphPickerHeadLocked,
    DiffScrollHint,
    DiffScrollDiscardHint,
    HelpJumpTab,
    JustNow,
    Keymap,
    GitLayout,
    LineStartEnd,
    /// The tree listing could not be rebuilt on a path that cannot propagate the error (the
    /// fs-watch refresh / a tab switch), so what is on screen may be out of date. See
    /// `App::refresh_reporting_staleness`. Followed by the underlying error text. One-shot, on the
    /// moment it goes stale; `StListingStale` is the chip that stays up while it *is* stale.
    ListingStale,
    /// Context-bar chip shown for as long as the listing is out of date (`App::tree_stale`).
    /// Deliberately a plain word, not a symbol: warning glyphs like `⚠` are East-Asian-Ambiguous
    /// width, so a CJK fallback font renders them two cells wide and pushes the whole bar over
    /// (the same trap `☐`/`☑` hit, and why the worktree chip is `WT`).
    StListingStale,
    Loading,
    Local,
    GitLogGraph,
    DlgMove,
    MarkHint,
    Match,
    MessageEmpty,
    TreeModified,
    GitMove,
    GitMoveCommit,
    TreeMoveUpDown,
    DlgCancel,
    NameEmpty,
    GitNewBranch,
    HelpNewTab,
    NoBookmark,
    NoBranches,
    NoChanges,
    NoCommits,
    NoCopyTarget,
    NoFileToEdit,
    NoMatch,
    NoTarget,
    NotAFile,
    NotAGitRepo,
    NotFound,
    NothingStaged,
    OpenFailed,
    OpenLinkHint,
    Opened,
    OperationFailed,
    PanHint,
    PathLabel,
    PrevNextTab,
    Quit,
    QuitOrCloseTab,
    Refresh,
    RelLabel,
    TreeStatusRenamed,
    ResetRoot,
    ResetFit,
    Root,
    StGitHubKeys,
    Scroll,
    Scroll10Lines,
    SearchHint,
    SearchCodeTextOnly,
    TableSearchHelp,
    SelLabel,
    SortHint,
    StageHint,
    Symlink,
    ToParent,
    ToggleHidden,
    ToggleOne,
    ToggleHelp,
    TopBottom,
    TrailingSlashFolder,
    UnstageHint,
    Untracked,
    VisualRangeHint,
    DlgTrash,
    DlgApply,
    DlgDeleteSafe,
    DlgYesNo,
    StTrashDelete,
    StApply,
    StDeleteForce,
    Zoom,
    BmActions,
    Empty,
    StBatchRename,
    StBookmarks,
    StTabs,
    StOutline,
    TabsTitle,
    TabsActions,
    OutlineTitle,
    OutlineActions,
    HelpTabList,
    StBranch,
    StChanges,
    StCommit,
    StCommitDiff,
    StCreate,
    StDelete,
    StDiff,
    StDrop,
    /// App-quit confirmation: dialog message, status chip, and footer hint.
    QuitConfirm,
    /// Extra line in the quit confirmation while a background file operation is still running.
    QuitWhileFileOp,
    /// Extra line in the quit confirmation while a background git write is still running.
    QuitWhileGitOp,
    StQuit,
    StQuitHint,
    StFilter,
    /// Help heading for the hub when jj answers.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjChangesLabel,
    /// Help heading for the graph when jj answers.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjGraphLabel,
    /// Help row: closing the hub, named after the system that filled it.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjCloseView,
    /// Help row: the whole working copy's diff, in jj's words.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjDiffAll,
    /// Help row: bookmarks, jj's name for its named pointers.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjBookmarksRow,
    /// Help row: the external tool `!` opens in a jj repository.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjExternalTool,
    /// Help row: `R` asks jj to snapshot the working copy.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjSyncRow,
    /// Help row: `a` widens the graph to every revision.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjGraphAllRow,
    /// Flash on `w` in a jj repository: konoma does not list jj workspaces yet.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjWorkspacesUnlisted,
    /// Confirmation before letting jj take a snapshot.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjSyncConfirm,
    /// Flash after a successful snapshot.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjSyncDone,
    /// Flash when the snapshot could not be taken.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjSyncFailed,
    /// Flash on `R` outside a jj repository.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjSyncNotJj,
    /// `!` failed to launch, when jj is the backend and the tool is jj's.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjToolFailed,
    /// Copy-menu label where the identity is a change ID rather than a hash (jj).
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkChangeId,
    /// Copy-menu label for the underlying commit ID in a system that names commits some other way.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkCommitId,
    /// Graph keys for a backend with a narrower default range: `GitNavDetailCommitHint` plus `a`.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    JjGraphNavHint,
    /// Flash on `a` in the graph when the backend already draws everything.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    GraphAlreadyAll,
    /// Flash on `a`: the graph widened to every revision.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    GraphShowingAll,
    /// Flash on `a`: the graph narrowed back to the backend's own range.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    GraphShowingDefault,
    /// The pointer list's chip when jj is answering: it lists bookmarks, not branches.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    StBookmark,
    /// Pointer-list keys for a backend that cannot write: no checkout, no create, no delete.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    BookmarksNavHint,
    /// Hub keys for a backend that cannot write: no staging, no commit, no worktrees, and jj's
    /// pointers are bookmarks.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    StJjHubKeys,
    /// Diff-view keys for a backend that cannot write: `DiffScrollDiscardHint` without `x:discard`.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    DiffScrollNoDiscardHint,
    StGit,
    /// Flash when a write is asked of a backend that only reads (jj).
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    VcsReadOnly,
    /// Status-bar chip when a jj (Jujutsu) backend is answering, in place of `StGit`.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    StJj,
    StGraph,
    StImage,
    StInfo,
    StLog,
    StMark,
    StPreview,
    StRename,
    StRenameConfirm,
    StSearch,
    StSort,
    StTree,
    StVisual,
    HintAnchor,
    WkCreate,
    AgoDays,
    WkDelete,
    HintDiff,
    HintEdit,
    HintEnds,
    HintEnter,
    HintFileOps,
    HintFilter,
    HintFit,
    WkFull,
    HintGit,
    HintBookmarks,
    HintHelp,
    HintHidden,
    AgoHr,
    HintHscroll,
    HintInfo,
    HintLineEnds,
    HintLink,
    HintMark,
    HintToggle,
    BusyGitScan,
    /// Busy-indicator label while the `/` filter's population walk finishes in the background.
    BusyFilterScan,
    BusyMedia,
    BusyHighlight,
    BusyImages,
    BusyFileOp,
    FileOpBusy,
    /// Busy-indicator label while a git write runs in the background.
    BusyGitOp,
    /// Rejection flash when a second git write is requested while one is still running.
    GitOpBusy,
    TaskFileChanged,
    AgoMin,
    AgoMonths,
    WkName,
    HintOpen,
    HintPage,
    HintFileJump,
    PreviewFileJumpHelp,
    HintPan,
    WkParent,
    WkPaste,
    WkDuplicate,
    HintPath,
    HintPick,
    HintQuit,
    HintCloseTab,
    HintRawSource,
    HintOutline,
    HintRendered,
    MdRawToggleHelp,
    WkRelative,
    WkRename,
    HintSearch,
    HintSort,
    HintTab,
    HintUp,
    HintVisual,
    AgoYears,
    WkCopyPathTitle,
    // --- CSV/TSV table preview ---
    StTable,
    PreviewTable,
    WkTableCopyTitle,
    WkCell,
    WkRow,
    WkColumn,
    HintCell,
    TableMoveHelp,
    TableColsHelp,
    // --- Table-cell full-text popup (`Enter`) ---
    StTableCell,
    TableCellTitle,
    TableCellActions,
    HintViewCell,
    TableCellViewHelp,
    TableCellEmpty,
    // --- Text/code preview selection (v = character range / V = line) ---
    PreviewVisualHint,
    PreviewVisualLineHint,
    /// Long, explanatory wording for the `?` help screen only. The footer wants the short
    /// `HintSelect` instead — a full sentence there eats the whole line and pushes the sibling
    /// hints off into the `…`.
    PreviewSelectHelp,
    /// Short footer label for `v`/`V` (range selection). Sibling of the other `Hint*` footer words.
    HintSelect,
    StVisualLine,
    // --- Agent Watch (① changed filter ② follow ③ @-reference copy) ---
    WkAtRef,
    /// which-key label for `y → c`: copy the focused Markdown code block.
    WkCodeBlock,
    StChangedOnly,
    ChangedFilterHint,
    NoChangedFiles,
    JumpTargetHidden,
    StFollow,
    FollowOn,
    FollowOff,
    FollowShowSince,
    FollowShowFull,
    HintFollowScope,
    ChangedFilterHelp,
    JumpChangeHelp,
    FollowHelp,
    AtRefHelp,
    PasteJumpHelp,
    PasteJumpNoClipboard,
    PasteJumpUnrecognized,
    PasteJumpNotFound,
    HintPasteJump,
    HintNewTab,
    OpenLinkNewTabHelp,
    MermaidZoomHelp,
    OpenInNewTabHelp,
    BookmarkOverwriteConfirm,
    StMarkOverwrite,
    StMarkOverwriteHint,
    // The following are labels dedicated to the git copy feature. They aren't constructed under
    // no-git, so dead_code is allowed.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkGitCopyTitle,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkShortHash,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkFullHash,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkSubject,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkMessage,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkAuthor,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    WkDate,
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    NoCommitToCopy,
    ImageUnsupported,
    PreviewTruncated,
    VideoThumbUnavailable,
    PdfPreviewUnavailable,
    ArchiveListUnavailable,
    MermaidUnavailable,
    DiagramOpenFailed,
    /// Preview body for a `detached=true` `[[preview.rules]] command = "..."` delegation, once launched.
    CommandOpenedExternally,
    /// Prefix before a delegated command's failure reason (missing binary / non-zero exit / `{out}`
    /// never produced) in the `[can not preview]` fallback.
    CommandPreviewFailed,
    MermaidCaption,
    MermaidZoomAffordance,
    MermaidPanAffordance,
    /// Status chip for the `?` help overlay (`internal_mode() == Some(InternalMode::Help)`).
    StHelp,
    /// Footer hint for the help overlay (its own j/k/g/G/q keys, not the surface behind it).
    StHelpHint,
    /// `o`/`d` etc. when `[external] git = false` (Git views unavailable by config, not because this
    /// isn't a repo).
    ExternalGitDisabled,
    /// `o`/`d` etc. when the config allows git but no `git` executable exists on this machine
    /// (distinct from `NotAGitRepo`: the directory may well be a repository — repo discovery goes
    /// through the embedded libgit2 and does not need the binary). Only ever constructed in the `git`
    /// build: the no-git build has no way to probe for a git executable (git support itself is compiled
    /// out), so it never claims "git is not installed" there.
    #[cfg_attr(not(feature = "git"), allow(dead_code))]
    GitNotInstalled,
    /// `O` when `[external] git_tool = false`.
    ExternalGitToolDisabled,
    /// Opening a link/file (Markdown link, `P`, ...) when `[external] open_links = false`.
    ExternalOpenLinksDisabled,
    // --- fileops error translation (`App::describe_error`/`build_rename_plan`) ---
    /// A create/rename target already exists. Shared by `fileops::FileOpError::AlreadyExists`
    /// (create/rename) and `build_rename_plan`'s own final-collision check (same condition, one
    /// wording — see the call site in `app.rs`).
    AlreadyExists,
    /// `fileops::FileOpError::TrashFailed`: moving to Trash failed (the OS trash service itself,
    /// not a missing file — the underlying error is kept as `source()` for logs/debugging).
    TrashFailed,
    /// `fileops::FileOpError::RenameTempExists`: batch rename's temp staging name already exists
    /// (a defensive, effectively unreachable check — see the variant's own doc comment).
    RenameTempExists,
    /// `fileops::FileOpError::RenameDestExists`: batch rename's own destination re-check found the
    /// name already taken (distinct from `AlreadyExists`: this is the apply phase, not the
    /// create/rename dialog).
    RenameDestExists,
    /// `fileops::FileOpError::NameUnavailable`: could not determine a name for the copy/move
    /// source (e.g. it's `/`).
    NameUnavailable,
    /// `fileops::FileOpError::RenameStageFailed`: batch rename's `rename()` call itself failed
    /// while staging a source aside to its temp name.
    RenameStageFailed,
    /// `fileops::FileOpError::RenameCommitFailed`: batch rename's `rename()` call itself failed
    /// while committing a temp name to its final destination.
    RenameCommitFailed,
    /// `fileops::RollbackIncomplete`: a failed batch rename could not undo itself either, so
    /// entries are left under `.konoma-rename-tmp-*` (or under their new name) and need cleaning
    /// up by hand. Followed by the list of those paths.
    RollbackIncomplete,
    /// `build_rename_plan`: the rendered name is empty (e.g. an all-`{ext}` template on a file
    /// with no extension).
    RenameEmptyName,
    /// `build_rename_plan`: the rendered name contains `/` (would create a path, not a name).
    RenameSlashInName,
    /// `build_rename_plan`: two targets rendered to the same final name within the same batch.
    RenameDestDuplicate,
}

/// English table.
fn en(msg: Msg) -> &'static str {
    use Msg::*;
    match msg {
        GitNoBranchesItem => "  (no branches)",
        GitNoWorktreesItem => "  (no worktrees)",
        GitWorktreesLabel => "Git worktrees (w)",
        NoWorktrees => "no worktrees",
        WorktreeIsBare => "bare repository — it has no checkout",
        WorktreeUnavailable => "worktree is missing (run `git worktree prune`)",
        WorktreeAlreadyCurrent => "already in this worktree",
        WorktreesNavHint => "j/k:nav  Enter:switch  n:new  Ctrl-t:new tab  d:diff  /:search  q/Esc:back",
        StWorktrees => "WORKTREES",
        StWorktreeChip => "WT",
        GitWorktreeSwitch => "switch to it",
        GitWorktreesRow => "worktrees",
        WorktreeShowChangesHelp => "diff since base (or uncommitted)",
        WorktreeCreateHelp => "new worktree (new or existing branch)",
        NewWorktree => "New worktree: branch name",
        CreatedWorktree => "Created worktree",
        GitNoChangesItem => "  (no changes)",
        GitNoCommitsItem => "  (no commits)",
        BmTitle => " Bookmarks ",
        DlgConfirmTitle => " Confirm ",
        DlgDropTitle => " Drop ",
        HelpTitle => " Help  (?/Esc to close, j/k to scroll) ",
        InfoTitle => " Info ",
        DlgInputTitle => " Input ",
        DlgRenamePreviewTitle => " Rename preview ",
        DlgDeletePermanentHint => "! = Delete permanently (no undo)",
        DlgForceDeleteHint => "! = force delete (-D)",
        BmEmpty => "(no bookmarks)",
        GitNoChanges => "(no changes)",
        BatchRename => "Batch rename",
        GitCommitWorktreeDetail => "Commit / worktree detail",
        CommitMessage => "Commit message",
        Committed => "Committed",
        Copied => "Copied",
        Create => "Create",
        Created => "Created",
        CreatedBranch => "Created branch",
        StScrollHintCtrl => "Ctrl-f/Ctrl-b page, Ctrl-d/Ctrl-u half (PgDn/Up too)",
        CutDone => "Cut",
        DeleteTarget => "Delete",
        DeleteBranch => "Delete branch",
        DeletedBranch => "Deleted branch",
        DeletedPermanently => "Deleted permanently",
        DiscardChangesTo => "Discard changes to",
        Discarded => "Discarded",
        StApplyClearHint => "Enter:apply Esc:clear",
        StCommitHint => "Enter:commit  Esc:cancel   (uses staged index)",
        StCreateHint => "Enter:create  Esc:cancel   (trailing / = folder)",
        StRenamePreviewHint => "Enter:preview  Esc:cancel   {n} {n:0W} {name} {ext}",
        StRenameHint => "Enter:rename  Esc:cancel   ←→ move  Del erase",
        StSearchHint => "Enter:search Esc:cancel",
        TreeFile => "File",
        GitBranchesLabel => "Git branches (b)",
        GitChangesLabel => "Git changes (o)",
        TreeGitChangesHub => "Git changes hub (stage/unstage/discard/commit; l=log g=graph b=branch)",
        GitGraphLabel => "Git graph (g)",
        GitLogLabel => "Git log (l)",
        TreeGitStatus => "Git status (row markers)",
        BmGlobal => "Global",
        HelpGlobal => "Global",
        BmLocal => "Local",
        InfoModified => "Modified",
        Moved => "Moved",
        MovedToTrash => "Moved to Trash",
        NewBranch => "New branch",
        Pasted => "Pasted",
        Duplicated => "Duplicated",
        InfoPerm => "Perm",
        PreviewGitDiff => "Preview: git diff",
        PreviewImage => "Preview: image",
        PreviewTextMarkdown => "Preview: text / Markdown",
        Rename => "Rename",
        Renamed => "Renamed",
        TreeSelection => "Selection",
        InfoSize => "Size",
        StPagerSpaceHint => "Space/b page, d/u half (PgDn/Up too)",
        Staged => "Staged",
        StagedAll => "Staged all",
        SwitchedTo => "Switched to",
        HelpTabs => "Tabs",
        InfoTarget => "Target",
        TreeSection => "Tree",
        InfoType => "Type",
        UncommittedChanges => "Uncommitted changes",
        Unstaged => "Unstaged",
        UnstagedAll => "Unstaged all",
        Highlighting => "[highlighting…] ",
        // Preview scroll position, vim's `%P` wording. Kept to three columns so it fits next to the
        // path in a title bar.
        ScrollTop => "Top",
        ScrollBot => "Bot",
        ScrollAll => "All",
        StSortHint => "[n]ame [s]ize [m]od [e]xt  [r]everse [.]dirs-1st  Esc",
        StPathAbs => "abs",
        TreeAddedStaged => "added (staged)",
        AlreadyAtStartDir => "already at start dir",
        AlreadyRoot => "already root",
        AnchorReset => "anchor reset",
        TreeAnchorRoot => "anchor root at current location",
        GitBack => "back",
        BackToGitView => "back to Git view",
        BackToChanges => "back to changes",
        BackToTree => "back to tree",
        TreeBookmarkHint => "bookmark cursor item: m=set, '=list (press a-z/A-Z to jump: file→preview/dir→cd)",
        PreviewBookmarkHint => "bookmark this file (a-z local / A-Z global) / open bookmark list",
        BookmarkTargetMissing => "bookmark target missing",
        Bookmarked => "bookmarked",
        GitBranches => "branches",
        DlgCopyKey => "c = copy",
        StCopyMoveHint => "c:copy  m:move  n/Esc:cancel",
        CantCloseLastTab => "can't close the last tab",
        Canceled => "canceled",
        CannotDeleteCurrentBranch => "cannot delete the current branch",
        CannotEditDirectory => "cannot edit a directory",
        CannotPasteIntoSelf => "cannot paste into itself",
        GitCheckout => "checkout",
        ClipboardEmpty => "clipboard is empty",
        GitCloseView => "close git view",
        GitCommit => "commit (staged)",
        GitCommitDetail => "commit detail (diff)",
        CopiedPrefix => "copied: ",
        WatchFailedPrefix => "auto-refresh disabled (failed to watch): ",
        CopyHint => "copy",
        CopyFailed => "copy failed: ",
        CopiedCodeBlock => "copied code block",
        HintCopyCode => "copy code",
        CutHint => "cut",
        CyclePathStyle => "cycle path style (rel/~/abs)",
        GitDelete => "delete (y=-d / !=-D)",
        TreeDeleted => "deleted",
        GitDetail => "detail (commit diff / worktree diff)",
        GitDiffAll => "diff of all changes (worktree)",
        TreeDiffFile => "diff of cursor file (git-changed)",
        DiffAuto => "diff: auto",
        DiffSideBySide => "diff: side-by-side",
        DiffUnified => "diff: unified",
        InfoDirectory => "directory",
        GitDiscardFile => "discard file (confirm)",
        DiscardWholeFile => "discard whole file (confirm)",
        TreeDragDrop => "drag & drop",
        TreeDropFiles => "drop file(s) → copy/move into cursor dir",
        DroppedItems => "dropped item(s)",
        EditExternal => "edit in external editor",
        EditExternalEnv => "edit in external editor ($EDITOR / config)",
        EditorFailed => "editor failed: ",
        EnterDirectory => "enter directory / open file",
        Etc => "etc.",
        ExpandInPlace => "expand in place / open file",
        GitExternalTool => "external git tool (lazygit)",
        Failed => "failed",
        InfoFile => "file",
        GitFileDiff => "file diff",
        TreeFileInfo => "file info (size/modified/permissions)",
        TreeFilter => "filter / recursive find (Esc to clear)",
        GitFilterByName => "filter by name",
        FocusMdLink => "focus md link / checkbox / code block / diagram (y c = copy code)",
        MdTaskToggleHelp => "toggle focused checkbox (writes to the file)",
        HintDetailsToggle => "expand/collapse the focused <details>",
        GitToolFailed => "git tool failed: ",
        JjToolFailed => "jj tool failed: ",
        JjChangesLabel => "jj changes (o)",
        JjGraphLabel => "jj graph (g)",
        JjCloseView => "close jj view",
        JjDiffAll => "diff of everything against @-",
        JjBookmarksRow => "bookmarks",
        JjExternalTool => "external jj tool (lazyjj)",
        JjSyncRow => "let jj snapshot the working copy (confirm)",
        JjGraphAllRow => "show every revision",
        JjWorkspacesUnlisted => "konoma does not list jj workspaces yet — `jj workspace list` does",
        JjSyncConfirm => "Let jj snapshot the working copy? (jj undo reverses it)",
        JjSyncDone => "jj snapshotted the working copy",
        JjSyncFailed => "jj could not snapshot the working copy",
        JjSyncNotJj => "nothing to sync: this is not a jj repository",
        GlobalApp => "global",
        HScroll => "horizontal scroll",
        GitHScrollEnds => "hscroll / line ends",
        StCloseHint => "i / Esc / q : close",
        InfoClose => "i / Esc / q close",
        AnchorNotFound => "no heading for anchor: ",
        OutlineEmpty => "no headings in this document",
        InvalidMarkKey => "invalid mark key",
        Items => "items",
        InfoItems => "items",
        VisualOpsHint => "j/k:extend  a:this-dir  A:all  v:commit  Space:ops(d/r/c/x)  Esc:cancel",
        BranchesNavHint => "j/k:nav  Enter:checkout  n:new  d:delete  /:search  q/Esc:back",
        BookmarksNavHint => "j/k:nav  /:search  q/Esc:back",
        GitNavDetailHint => "j/k:nav  Enter:detail  q/Esc:back",
        GitNavDetailCommitHint => {
            "j/k:nav  Enter:detail  s:base  x/0:base off  b:branches  q/Esc:back"
        }
        JjGraphNavHint => "j/k:nav  Enter:detail  a:all revisions  b:bookmarks  q/Esc:back",
        GraphBaseSet => "base: ",
        GraphBaseCleared => "base cleared",
        GraphBaseNeedsCommit => "select a commit to set as base",
        GraphSetBaseHelp => "pin the selected commit's branch as the base (leftmost lane)",
        GraphClearBaseHelp => "clear the pinned base",
        GraphBranchesHelp => "choose which branches are shown",
        GraphLegendHidden => "hidden",
        GraphPickerTitle => "Graph branches",
        GraphPickerFooter => {
            "Space:toggle  J/K:reorder  a:all  n:current only  Enter:apply  q:cancel"
        }
        GraphPickerHeadLocked => "current branch (HEAD) is always shown",
        DiffScrollHint => "j/k:scroll  h/l:hscroll  s:unified/split/auto  g/G:ends  q/Esc:back",
        DiffScrollDiscardHint => "j/k:scroll  n/N:next/prev file  h/l:hscroll  s:unified/split/auto  x:discard  q/Esc:back",
        DiffScrollNoDiscardHint => "j/k:scroll  n/N:next/prev file  h/l:hscroll  s:unified/split/auto  q/Esc:back",
        HelpJumpTab => "jump to tab by number",
        JustNow => "just now",
        Keymap => "keymap",
        GitLayout => "layout: unified / split / auto",
        LineStartEnd => "line start / line end (horizontal)",
        ListingStale => "listing may be out of date (refresh failed): ",
        StListingStale => "STALE",
        Loading => "loading…",
        Local => "local",
        GitLogGraph => "log / graph",
        DlgMove => "m = move",
        MarkHint => "mark ▸ a-z = local / A-Z = global   Esc",
        Match => "match",
        MessageEmpty => "message is empty",
        TreeModified => "modified",
        GitMove => "move",
        GitMoveCommit => "move (commit / uncommitted)",
        TreeMoveUpDown => "move up/down",
        DlgCancel => "n / Esc = cancel",
        NameEmpty => "name is empty",
        GitNewBranch => "new branch",
        HelpNewTab => "new tab",
        NoBookmark => "no bookmark",
        NoBranches => "no branches",
        NoChanges => "no changes",
        NoCommits => "no commits",
        NoCopyTarget => "no copy target",
        NoFileToEdit => "no file to edit",
        NoMatch => "no match",
        NoTarget => "no target",
        NotAFile => "not a file",
        NotAGitRepo => "not a git repo",
        NotFound => "not found: ",
        NothingStaged => "nothing staged",
        OpenFailed => "open failed: ",
        OpenLinkHint => "open link (URL=browser / local=konoma) / toggle checkbox / open diagram full screen",
        Opened => "opened: ",
        OperationFailed => "operation failed: ",
        PanHint => "pan (when zoomed/clipped)",
        PathLabel => "path:",
        PrevNextTab => "prev / next tab",
        Quit => "quit (back to tree in preview)",
        QuitOrCloseTab => "close tab, or quit if it is the last one (back to tree in preview)",
        Refresh => "refresh listing & git status",
        RelLabel => "rel",
        TreeStatusRenamed => "renamed / typechange / conflict",
        ResetRoot => "reset root to start directory",
        ResetFit => "reset to fit",
        Root => "root",
        StGitHubKeys => "s/S:stage(all) u/U:unstage(all) x:discard c:commit Enter:diff d:diff-all l:log g:graph b:branch w:worktrees !:tool q:close",
        StJjHubKeys => "Enter:diff d:diff-all l:log g:graph b:bookmarks R:sync !:tool q:close",
        Scroll => "scroll",
        Scroll10Lines => "scroll 10 lines",
        SearchHint => "search (code/text); next / prev match",
        SearchCodeTextOnly => "search: code/text and table previews only",
        TableSearchHelp => "search cells; n / N jump to the next / previous match",
        SelLabel => "sel",
        SortHint => "sort: name/size/mod/ext, r=reverse, .=dirs first",
        StageHint => "stage / stage all",
        Symlink => "symlink",
        ToParent => "to parent directory",
        ToggleHidden => "toggle hidden files",
        ToggleOne => "toggle one item (pick scattered), Esc = clear selection",
        ToggleHelp => "toggle this help",
        TopBottom => "top / bottom",
        TrailingSlashFolder => "trailing / = folder",
        UnstageHint => "unstage / unstage all",
        Untracked => "untracked",
        VisualRangeHint => "visual range: j/k extend, v/Esc commit, a=this dir / A=all, Space=ops",
        DlgTrash => "y = Trash (recoverable)",
        DlgApply => "y = apply    Esc = cancel    j/k = scroll",
        DlgDeleteSafe => "y = delete (safe, -d)",
        DlgYesNo => "y = yes    n / Esc = no",
        StTrashDelete => "y:Trash  !:delete permanently  n/Esc:cancel",
        StApply => "y:apply  Esc:cancel  j/k:scroll",
        StDeleteForce => "y:delete(-d)  !:force(-D)  n/Esc:cancel",
        Zoom => "zoom",
        BmActions => "a-Z jump   ↵ open   ^E edit   ^D delete   q close",
        Empty => "",
        StBatchRename => "BATCH RENAME",
        StBookmarks => "BOOKMARKS",
        StTabs => "TABS",
        StOutline => "OUTLINE",
        TabsTitle => " Tabs ",
        TabsActions => "1-9/↵ switch   d close tab   T·q·Esc close",
        OutlineTitle => " Outline ",
        OutlineActions => "j/k move   ↵ jump   o·q·Esc close",
        HelpTabList => "tab list (switch / close)",
        GraphAlreadyAll => "the graph already shows every commit",
        GraphShowingAll => "showing every revision",
        GraphShowingDefault => "showing the default range",
        StBookmark => "BOOKMARK",
        StBranch => "BRANCH",
        StChanges => "CHANGES",
        StCommit => "COMMIT",
        StCommitDiff => "COMMIT DIFF",
        StCreate => "CREATE",
        StDelete => "DELETE",
        StDiff => "DIFF",
        StDrop => "DROP",
        QuitConfirm => "Quit konoma?",
        QuitWhileFileOp => "a file operation is still running — quitting will interrupt it",
        QuitWhileGitOp => "a git operation is still running — quitting will interrupt it",
        StQuit => "QUIT",
        StQuitHint => "y / q / Enter = quit    n / Esc = cancel",
        StFilter => "FILTER",
        VcsReadOnly => "konoma only reads a jj repository — use jj itself to change it",
        StGit => "GIT",
        StJj => "JJ",
        StGraph => "GRAPH",
        StImage => "IMAGE",
        StInfo => "INFO",
        StLog => "LOG",
        StMark => "MARK",
        StPreview => "PREVIEW",
        StTable => "TABLE",
        PreviewTable => "CSV / TSV table",
        WkTableCopyTitle => "Copy from table",
        WkCell => "cell",
        WkRow => "row",
        WkColumn => "column",
        HintCell => "cell",
        TableMoveHelp => "move between cells",
        TableColsHelp => "first / last column",
        StTableCell => "CELL",
        TableCellTitle => "Cell",
        TableCellActions => "j/k:scroll  g/G:top/bottom  q/Esc:close",
        HintViewCell => "view cell",
        TableCellViewHelp => "view the full cell text (wraps; scroll with j/k)",
        TableCellEmpty => "no cell to view",
        PreviewVisualHint => "h / j / k / l: extend    y: copy    Y: @ref    v / Esc: cancel",
        PreviewVisualLineHint => "j / k / g / G: extend    y: copy lines    Y: @ref    V / Esc: cancel",
        PreviewSelectHelp => "v: select a character range   V: select whole lines (copy with y)",
        HintSelect => "select",
        StVisualLine => "V-LINE",
        WkAtRef => "@ref",
        WkCodeBlock => "code block",
        StChangedOnly => "CHANGED",
        ChangedFilterHint => "Enter: preview  n / N: next / prev  C / h: all files",
        NoChangedFiles => "no changed files",
        JumpTargetHidden => "target is inside a hidden directory (`.` to show hidden files)",
        StFollow => "FOLLOW",
        FollowOn => "follow: on (q stops)",
        FollowOff => "follow: off",
        FollowShowSince => "since follow start",
        FollowShowFull => "full diff",
        HintFollowScope => "full/since",
        ChangedFilterHelp => "show changed files only (git)",
        JumpChangeHelp => "jump to next / previous changed file",
        FollowHelp => "follow mode: auto-preview externally changed files",
        AtRefHelp => "copy @path#L reference of caret / selection",
        PasteJumpHelp => "paste a path / GitHub link and jump there (reveal + preview)",
        PasteJumpNoClipboard => "clipboard is empty or unavailable",
        PasteJumpUnrecognized => "no path found in the clipboard",
        PasteJumpNotFound => "path not found: ",
        HintPasteJump => "goto path",
        HintNewTab => "new tab",
        OpenLinkNewTabHelp => "open the focused link in a new tab",
        MermaidZoomHelp => "zoom the focused diagram in place (hjkl pan while zoomed, 0 fits)",
        OpenInNewTabHelp => "open the entry under the cursor in a new tab",
        BookmarkOverwriteConfirm => "Overwrite bookmark",
        StMarkOverwrite => "OVERWRITE?",
        StMarkOverwriteHint => "y / Enter: overwrite   n / Esc: cancel",
        StRename => "RENAME",
        StRenameConfirm => "RENAME?",
        StSearch => "SEARCH",
        StSort => "SORT",
        StTree => "TREE",
        StVisual => "VISUAL",
        HintAnchor => "anchor",
        WkCreate => "create",
        AgoDays => "days ago",
        WkDelete => "delete",
        HintDiff => "diff",
        HintEdit => "edit",
        HintEnds => "ends",
        HintEnter => "enter",
        HintFileOps => "file ops",
        HintFilter => "filter",
        HintFit => "fit",
        WkFull => "full",
        HintGit => "git",
        HintBookmarks => "bookmarks",
        HintHelp => "help",
        HintHidden => "hidden",
        AgoHr => "hr ago",
        HintHscroll => "hscroll",
        HintInfo => "info",
        HintLineEnds => "line ends",
        HintLink => "link",
        HintMark => "mark",
        HintToggle => "toggle",
        BusyGitScan => "git scan",
        BusyFilterScan => "scanning files",
        BusyMedia => "loading media",
        BusyHighlight => "highlighting",
        BusyImages => "loading images",
        BusyFileOp => "file op",
        FileOpBusy => "another file operation is still running",
        BusyGitOp => "git",
        GitOpBusy => "another git operation is still running",
        // Since the `md-block-walk` migration (2026-08), this really does mean the file changed on
        // disk since the last render: `md_toggle_focused_task` reads the checkbox's position straight
        // off the render pass's own record (no independent re-scan to disagree with it — see
        // `MdItemKind::Task::state_at`'s own doc comment), so the on-disk prefix comparison this
        // flashes for is a genuine external-edit detector, not a renderer/scanner drift.
        TaskFileChanged => "couldn't toggle checkbox — reloaded",
        AgoMin => "min ago",
        AgoMonths => "months ago",
        WkName => "name",
        HintOpen => "open",
        HintPage => "page",
        HintFileJump => "next/prev file",
        PreviewFileJumpHelp => "preview the next / previous file (tree order, wraps)",
        HintPan => "pan",
        WkParent => "parent",
        WkPaste => "paste",
        WkDuplicate => "duplicate",
        HintPath => "path",
        HintPick => "pick",
        HintQuit => "quit",
        HintCloseTab => "close tab",
        HintRawSource => "raw source",
        HintOutline => "outline",
        HintRendered => "rendered",
        MdRawToggleHelp => "toggle rendered / raw source (raw is selectable)",
        WkRelative => "relative",
        WkRename => "rename",
        HintSearch => "search",
        HintSort => "sort",
        HintTab => "tab",
        HintUp => "up",
        HintVisual => "visual",
        AgoYears => "years ago",
        WkCopyPathTitle => "Copy path",
        WkGitCopyTitle => "Copy commit",
        WkChangeId => "change id",
        WkCommitId => "commit id",
        WkShortHash => "short hash",
        WkFullHash => "full hash",
        WkSubject => "subject",
        WkMessage => "message",
        WkAuthor => "author",
        WkDate => "date",
        NoCommitToCopy => "no commit to copy",
        ImageUnsupported => {
            "[image] cannot display image in this terminal, or failed to load"
        }
        PreviewTruncated => "\n\n— (truncated: display limit reached) —",
        VideoThumbUnavailable => {
            "[video] no thumbnail — install ffmpegthumbnailer or ffmpeg (and use a kitty-graphics terminal)"
        }
        PdfPreviewUnavailable => {
            "[pdf] cannot render — use a kitty-graphics terminal (or this PDF is encrypted/corrupt)"
        }
        ArchiveListUnavailable => {
            "[archive] cannot list entries — corrupt file or unsupported format"
        }
        MermaidUnavailable => "[mermaid] cannot render this diagram as an image — press q to go back",
        DiagramOpenFailed => "diagram not found (file changed?) — reopen the preview",
        CommandOpenedExternally => "opened externally: ",
        CommandPreviewFailed => "delegated command failed: ",
        // Inline-diagram caption/frame affordances. `MermaidCaption` keeps the word "Enter" so the
        // caption is the same in both languages up to that point (the `◇ mermaid` prefix is a render
        // sentinel and stays literal in code, so it is not translated here).
        MermaidCaption => "Enter: full screen",
        MermaidZoomAffordance => "+/-: zoom",
        MermaidPanAffordance => "hjkl:pan  0:fit",
        StHelp => "HELP",
        StHelpHint => "j/k:scroll  g/G:top/bottom  q/Esc:close",
        ExternalGitDisabled => "git integration is disabled (config: [external] git = false)",
        GitNotInstalled => "git is not installed — git integration is off",
        ExternalGitToolDisabled => "external git tool is disabled (config: [external] git_tool = false)",
        ExternalOpenLinksDisabled => "opening links/files is disabled (config: [external] open_links = false)",
        AlreadyExists => "already exists: ",
        TrashFailed => "failed to move to Trash",
        RenameTempExists => "temporary rename name already exists: ",
        RenameDestExists => "rename destination already exists: ",
        NameUnavailable => "could not determine a name: ",
        RenameStageFailed => "staging rename: ",
        RenameCommitFailed => "committing rename: ",
        RollbackIncomplete => "rollback also failed, clean up by hand: ",
        RenameEmptyName => "the rendered name is empty",
        RenameSlashInName => "name cannot contain /: ",
        RenameDestDuplicate => "duplicate rename destination: ",
    }
}

/// Japanese table.
fn jp(msg: Msg) -> &'static str {
    use Msg::*;
    match msg {
        GitNoBranchesItem => "  (ブランチなし)",
        GitNoWorktreesItem => "  (ワークツリーなし)",
        GitWorktreesLabel => "Git ワークツリー (w)",
        NoWorktrees => "ワークツリーなし",
        WorktreeIsBare => "ベアリポジトリ(実体のチェックアウトがありません)",
        WorktreeUnavailable => "ワークツリーが見つかりません(`git worktree prune` を実行してください)",
        WorktreeAlreadyCurrent => "既にこのワークツリーにいます",
        WorktreesNavHint => "j/k:移動  Enter:切替  n:新規  Ctrl-t:新規タブ  d:diff  /:検索  q/Esc:戻る",
        StWorktrees => "ワークツリー",
        StWorktreeChip => "WT",
        GitWorktreeSwitch => "切り替える",
        GitWorktreesRow => "ワークツリー",
        WorktreeShowChangesHelp => "base からの diff(無ければ未コミットのみ)",
        WorktreeCreateHelp => "新規ワークツリー(新規/既存ブランチ)",
        NewWorktree => "新規ワークツリーのブランチ名",
        CreatedWorktree => "ワークツリー作成",
        GitNoChangesItem => "  (変更なし)",
        GitNoCommitsItem => "  (コミットなし)",
        BmTitle => " ブックマーク ",
        DlgConfirmTitle => " 確認 ",
        DlgDropTitle => " ドロップ ",
        HelpTitle => " ヘルプ  (?/Esc で閉じる, j/k スクロール) ",
        InfoTitle => " 情報 ",
        DlgInputTitle => " 入力 ",
        DlgRenamePreviewTitle => " リネーム確認 ",
        DlgDeletePermanentHint => "! = 完全に削除 (復元不可)",
        DlgForceDeleteHint => "! = 強制削除 (-D)",
        BmEmpty => "(ブックマーク無し)",
        GitNoChanges => "(変更なし)",
        BatchRename => "一括リネーム",
        GitCommitWorktreeDetail => "コミット / 作業ツリー詳細",
        CommitMessage => "コミットメッセージ",
        Committed => "コミットしました",
        Copied => "コピー",
        Create => "作成",
        Created => "作成",
        CreatedBranch => "ブランチ作成",
        StScrollHintCtrl => "Ctrl-f/Ctrl-b ページ, Ctrl-d/Ctrl-u ハーフ (PgDn/Up 共通)",
        CutDone => "カット",
        DeleteTarget => "削除対象",
        DeleteBranch => "ブランチ削除",
        DeletedBranch => "ブランチ削除",
        DeletedPermanently => "完全に削除しました",
        DiscardChangesTo => "変更を破棄しますか:",
        Discarded => "破棄",
        StApplyClearHint => "Enter:確定 Esc:解除",
        StCommitHint => "Enter:コミット  Esc:取消   (ステージ済みを使用)",
        StCreateHint => "Enter:作成  Esc:取消   (末尾 / でフォルダ)",
        StRenamePreviewHint => "Enter:確認へ  Esc:取消   {n} {n:0W} {name} {ext}",
        StRenameHint => "Enter:リネーム  Esc:取消   ←→ 移動  Del 削除",
        StSearchHint => "Enter:検索 Esc:解除",
        TreeFile => "ファイル管理",
        GitBranchesLabel => "Git ブランチ (b)",
        GitChangesLabel => "Git 変更ハブ (o)",
        TreeGitChangesHub => "Git 変更ハブ (ステージ/解除/破棄/コミット; l=ログ g=グラフ b=ブランチ)",
        GitGraphLabel => "Git グラフ (g)",
        GitLogLabel => "Git ログ (l)",
        TreeGitStatus => "Git 状態 (行頭マーカー)",
        BmGlobal => "グローバル",
        HelpGlobal => "共通 (Global)",
        BmLocal => "ローカル",
        InfoModified => "更新",
        Moved => "移動",
        MovedToTrash => "ゴミ箱へ送りました",
        NewBranch => "新規ブランチ",
        Pasted => "ペースト",
        Duplicated => "複製",
        InfoPerm => "権限",
        PreviewGitDiff => "プレビュー: git 差分",
        PreviewImage => "プレビュー: 画像",
        PreviewTextMarkdown => "プレビュー: テキスト/Markdown",
        Rename => "リネーム",
        Renamed => "リネーム",
        TreeSelection => "選択",
        InfoSize => "サイズ",
        StPagerSpaceHint => "Space/b ページ, d/u ハーフ (PgDn/Up 共通)",
        Staged => "ステージ",
        StagedAll => "全てステージ",
        SwitchedTo => "切替",
        HelpTabs => "タブ (Tabs)",
        InfoTarget => "リンク先",
        TreeSection => "ツリー (Tree)",
        InfoType => "種別",
        UncommittedChanges => "未コミットの変更",
        Unstaged => "アンステージ",
        UnstagedAll => "全てアンステージ",
        Highlighting => "[ハイライト中…] ",
        ScrollTop => "先頭",
        ScrollBot => "末尾",
        ScrollAll => "全体",
        StSortHint => "[n]名前 [s]サイズ [m]更新 [e]拡張子  [r]反転 [.]フォルダ先頭  Esc",
        StPathAbs => "絶対",
        TreeAddedStaged => "追加(ステージ済)",
        AlreadyAtStartDir => "既に起動位置が基準",
        AlreadyRoot => "既にルート",
        AnchorReset => "アンカーを起動位置へ",
        TreeAnchorRoot => "現在地をルートに固定 (アンカー)",
        GitBack => "戻る",
        BackToGitView => "Git ビューへ戻る",
        BackToChanges => "変更ハブへ戻る",
        BackToTree => "ツリーへ戻る",
        TreeBookmarkHint => "ブックマーク(カーソル位置): m=登録, '=一覧(英字キーで直ジャンプ: ファイル→preview/dir→移動)",
        PreviewBookmarkHint => "表示中ファイルをブックマーク(a-z ローカル/A-Z グローバル) / 一覧を開く",
        BookmarkTargetMissing => "ブックマーク先が無い",
        Bookmarked => "登録",
        GitBranches => "ブランチ",
        DlgCopyKey => "c = コピー",
        StCopyMoveHint => "c:コピー  m:移動  n/Esc:取消",
        CantCloseLastTab => "最後のタブは閉じられません",
        Canceled => "取消",
        CannotDeleteCurrentBranch => "現在のブランチは削除できません",
        CannotEditDirectory => "ディレクトリは編集できません",
        CannotPasteIntoSelf => "自分自身へは貼れません",
        GitCheckout => "切替",
        ClipboardEmpty => "クリップボードが空",
        GitCloseView => "Git ビューを閉じる",
        GitCommit => "コミット (ステージ済み)",
        GitCommitDetail => "コミット詳細 (差分)",
        CopiedPrefix => "コピー: ",
        WatchFailedPrefix => "自動更新が無効です(監視に失敗): ",
        CopyHint => "コピー",
        CopyFailed => "コピー失敗: ",
        CopiedCodeBlock => "コードブロックをコピー",
        HintCopyCode => "コード",
        CutHint => "カット",
        CyclePathStyle => "パス表示の切替 (相対/~/絶対)",
        GitDelete => "削除 (y=-d / !=-D)",
        TreeDeleted => "削除",
        GitDetail => "詳細 (コミット差分 / 作業ツリー差分)",
        GitDiffAll => "全変更まとめ diff (作業ツリー)",
        TreeDiffFile => "カーソルの変更ファイルの diff を直接開く",
        DiffAuto => "diff: 自動(幅で縦/横)",
        DiffSideBySide => "diff: 横並び",
        DiffUnified => "diff: 縦(unified)",
        InfoDirectory => "ディレクトリ",
        GitDiscardFile => "ファイル破棄 (確認)",
        DiscardWholeFile => "ファイル全体を破棄(確認)",
        TreeDragDrop => "ドラッグ&ドロップ",
        TreeDropFiles => "ファイルをドロップ → カーソル位置へコピー/移動",
        DroppedItems => "個をドロップ",
        EditExternal => "外部エディタで編集",
        EditExternalEnv => "外部エディタで編集 ($EDITOR / 設定)",
        EditorFailed => "エディタ起動失敗: ",
        EnterDirectory => "ディレクトリへ降りる / ファイルを開く",
        Etc => "",
        ExpandInPlace => "その場で展開 / ファイルを開く",
        GitExternalTool => "外部 git ツール (lazygit)",
        Failed => "失敗",
        InfoFile => "ファイル",
        GitFileDiff => "ファイル差分",
        TreeFileInfo => "ファイル情報 (サイズ/更新/権限)",
        TreeFilter => "絞り込み / 再帰検索 (Esc で解除)",
        GitFilterByName => "名前で絞り込み",
        FocusMdLink => "Markdown リンク/チェックボックス/コードブロック/mermaid図をフォーカス (y c=コードをコピー)",
        MdTaskToggleHelp => "フォーカス中のチェックボックスをトグル(ファイルに書込み)",
        HintDetailsToggle => "フォーカス中の <details> を開閉",
        GitToolFailed => "git ツール起動失敗: ",
        JjToolFailed => "jj ツール起動失敗: ",
        JjChangesLabel => "jj 変更ハブ (o)",
        JjGraphLabel => "jj グラフ (g)",
        JjCloseView => "jj ビューを閉じる",
        JjDiffAll => "@- との差分をまとめて表示",
        JjBookmarksRow => "ブックマーク",
        JjExternalTool => "外部 jj ツール (lazyjj)",
        JjSyncRow => "jj に作業コピーを取り込ませる (確認)",
        JjGraphAllRow => "全リビジョンを表示",
        JjWorkspacesUnlisted => "jj の workspace 一覧は未対応です — `jj workspace list` で見られます",
        JjSyncConfirm => "jj に作業コピーを取り込ませますか?(jj undo で戻せます)",
        JjSyncDone => "jj が作業コピーを取り込みました",
        JjSyncFailed => "jj が作業コピーを取り込めませんでした",
        JjSyncNotJj => "同期する対象がありません(jj リポジトリではありません)",
        GlobalApp => "グローバル",
        HScroll => "横スクロール(非折返し時)",
        GitHScrollEnds => "横スクロール / 行頭・行末",
        StCloseHint => "i / Esc / q : 閉じる",
        InfoClose => "i / Esc / q 閉じる",
        AnchorNotFound => "見出しが見つかりません: ",
        OutlineEmpty => "この文書に見出しはありません",
        InvalidMarkKey => "無効なマークキー",
        Items => "",
        InfoItems => "項目",
        VisualOpsHint => "j/k:範囲  a:同階層  A:全部  v:確定  Space:操作(d/r/c/x)  Esc:取消",
        BranchesNavHint => "j/k:移動  Enter:切替  n:新規  d:削除  /:検索  q/Esc:戻る",
        BookmarksNavHint => "j/k:移動  /:検索  q/Esc:戻る",
        GitNavDetailHint => "j/k:移動  Enter:詳細  q/Esc:戻る",
        GitNavDetailCommitHint => "j/k:移動  Enter:詳細  s:基準  x/0:基準解除  b:ブランチ  q/Esc:戻る",
        JjGraphNavHint => "j/k:移動  Enter:詳細  a:全リビジョン  b:ブックマーク  q/Esc:戻る",
        GraphBaseSet => "基準: ",
        GraphBaseCleared => "基準を解除しました",
        GraphBaseNeedsCommit => "基準にするコミットを選んでください",
        GraphSetBaseHelp => "選択コミットの枝を基準(左端レーン)に固定",
        GraphClearBaseHelp => "基準の固定を解除",
        GraphBranchesHelp => "表示するブランチを選ぶ",
        GraphLegendHidden => "非表示",
        GraphPickerTitle => "グラフのブランチ",
        GraphPickerFooter => "Space:切替  J/K:並替  a:全部  n:現在のみ  Enter:適用  q:取消",
        GraphPickerHeadLocked => "現在ブランチ(HEAD)は常に表示されます",
        DiffScrollHint => "j/k:スクロール  h/l:横移動  s:縦/横/Auto  g/G:先頭/末尾  q/Esc:戻る",
        DiffScrollDiscardHint => "j/k:スクロール  n/N:次/前の変更  h/l:横移動  s:縦/横/Auto  x:破棄  q/Esc:戻る",
        DiffScrollNoDiscardHint => "j/k:スクロール  n/N:次/前の変更  h/l:横移動  s:縦/横/Auto  q/Esc:戻る",
        HelpJumpTab => "番号でタブへジャンプ",
        JustNow => "たった今",
        Keymap => "キーマップ",
        GitLayout => "並び: 縦 / 横 / Auto",
        LineStartEnd => "行頭 / 行末へ(横)",
        ListingStale => "一覧が古いままの可能性 (更新に失敗): ",
        StListingStale => "古い一覧",
        Loading => "読み込み中…",
        Local => "ローカル",
        GitLogGraph => "ログ / グラフ",
        DlgMove => "m = 移動",
        MarkHint => "登録 ▸ a-z=ローカル / A-Z=グローバル   Esc",
        Match => "一致",
        MessageEmpty => "メッセージが空です",
        TreeModified => "変更あり",
        GitMove => "移動",
        GitMoveCommit => "移動 (コミット / 未コミット)",
        TreeMoveUpDown => "上下移動",
        DlgCancel => "n / Esc = 取消",
        NameEmpty => "名前が空です",
        GitNewBranch => "新規ブランチ",
        HelpNewTab => "新規タブ",
        NoBookmark => "ブックマーク無し",
        NoBranches => "ブランチなし",
        NoChanges => "変更なし",
        NoCommits => "コミットなし",
        NoCopyTarget => "コピー対象がありません",
        NoFileToEdit => "編集対象がありません",
        NoMatch => "一致なし",
        NoTarget => "対象がありません",
        NotAFile => "ファイルではありません",
        NotAGitRepo => "git リポジトリではありません",
        NotFound => "見つかりません: ",
        NothingStaged => "ステージ無し",
        OpenFailed => "起動失敗: ",
        OpenLinkHint => "リンクを開く (URL=ブラウザ/ローカル=konoma)・チェックボックスはトグル・mermaid図は全画面",
        Opened => "開きました: ",
        OperationFailed => "操作に失敗: ",
        PanHint => "パン(拡大して見切れた時)",
        PathLabel => "パス:",
        PrevNextTab => "前 / 次のタブ",
        Quit => "終了 (プレビュー中はツリーへ戻る)",
        QuitOrCloseTab => "タブを閉じる・最後の1つなら終了 (プレビュー中はツリーへ戻る)",
        Refresh => "一覧と git status を再読込",
        RelLabel => "相対",
        TreeStatusRenamed => "改名 / 種別変更 / 競合",
        ResetRoot => "ルートを起動ディレクトリへ戻す",
        ResetFit => "フィットに戻す",
        Root => "ルート",
        StGitHubKeys => "s/S:ステージ(全) u/U:解除(全) x:破棄 c:コミット Enter:差分 d:全変更差分 l:ログ g:グラフ b:ブランチ w:ワークツリー !:ツール q:閉じる",
        StJjHubKeys => "Enter:差分  d:全差分  l:ログ  g:グラフ  b:ブックマーク  R:同期  !:ツール  q:閉じる",
        Scroll => "スクロール",
        Scroll10Lines => "10 行スクロール",
        SearchHint => "検索(コード/テキスト); 次 / 前の一致",
        SearchCodeTextOnly => "検索はコード/テキストと表のみ対応",
        TableSearchHelp => "セルを検索(n / N で次/前の一致へ)",
        SelLabel => "選択",
        SortHint => "並び替え: 名前/サイズ/更新/拡張子, r=反転, .=フォルダ先頭",
        StageHint => "ステージ / 全ステージ",
        Symlink => "シンボリックリンク",
        ToParent => "親ディレクトリへ",
        ToggleHidden => "隠しファイル表示の切替",
        ToggleOne => "1件トグル(歯抜けを拾う), Esc = 選択クリア",
        ToggleHelp => "このヘルプの開閉",
        TopBottom => "先頭 / 末尾",
        TrailingSlashFolder => "末尾 / でフォルダ",
        UnstageHint => "アンステージ / 全アンステージ",
        Untracked => "未追跡",
        VisualRangeHint => "ビジュアル範囲: j/k で伸ばす, v/Esc 確定, a=同階層/A=表示全部, Space=操作",
        DlgTrash => "y = ゴミ箱へ送る (復元可)",
        DlgApply => "y = 適用    Esc = 取消    j/k = スクロール",
        DlgDeleteSafe => "y = 削除 (安全 -d)",
        DlgYesNo => "y = 実行    n / Esc = 取消",
        StTrashDelete => "y:ゴミ箱  !:完全削除  n/Esc:取消",
        StApply => "y:適用  Esc:取消  j/k:スクロール",
        StDeleteForce => "y:削除(-d)  !:強制(-D)  n/Esc:取消",
        Zoom => "ズーム",
        BmActions => "a-Z ジャンプ   ↵ 開く   ^E 編集   ^D 削除   q 閉じる",
        Empty => "",
        StBatchRename => "一括リネーム",
        StBookmarks => "ブックマーク",
        StTabs => "タブ",
        StOutline => "アウトライン",
        TabsTitle => " タブ一覧 ",
        TabsActions => "1-9/↵ 切替   d タブを閉じる   T·q·Esc 閉じる",
        OutlineTitle => " アウトライン ",
        OutlineActions => "j/k 移動   ↵ ジャンプ   o·q·Esc 閉じる",
        HelpTabList => "タブ一覧(切替 / 閉じる)",
        GraphAlreadyAll => "グラフは既に全コミットを表示しています",
        GraphShowingAll => "全リビジョンを表示",
        GraphShowingDefault => "既定の範囲を表示",
        StBookmark => "ブックマーク",
        StBranch => "ブランチ",
        StChanges => "変更",
        StCommit => "コミット",
        StCommitDiff => "コミット差分",
        StCreate => "作成",
        StDelete => "削除確認",
        StDiff => "差分",
        StDrop => "ドロップ",
        QuitConfirm => "konoma を終了しますか?",
        QuitWhileFileOp => "ファイル操作が実行中です — 終了すると中断されます",
        QuitWhileGitOp => "git 操作が実行中です — 終了すると中断されます",
        StQuit => "終了確認",
        StQuitHint => "y / q / Enter = 終了    n / Esc = 取消",
        StFilter => "絞り込み",
        VcsReadOnly => "konoma は jj リポジトリを読むだけです — 変更は jj で行ってください",
        StGit => "Git",
        StJj => "jj",
        StGraph => "グラフ",
        StImage => "画像",
        StInfo => "情報",
        StLog => "ログ",
        StMark => "登録",
        StPreview => "プレビュー",
        StTable => "テーブル",
        PreviewTable => "CSV / TSV テーブル",
        WkTableCopyTitle => "テーブルからコピー",
        WkCell => "セル",
        WkRow => "",
        WkColumn => "",
        HintCell => "セル",
        TableMoveHelp => "セル間を移動",
        TableColsHelp => "先頭 / 末尾の列",
        StTableCell => "セル",
        TableCellTitle => "セル",
        TableCellActions => "j/k:スクロール  g/G:先頭/末尾  q/Esc:閉じる",
        HintViewCell => "セル表示",
        TableCellViewHelp => "セルの全文を表示(折返し・j/k でスクロール)",
        TableCellEmpty => "表示できるセルがありません",
        PreviewVisualHint => "h / j / k / l: 範囲拡張    y: コピー    Y: @参照    v / Esc: 取消",
        PreviewVisualLineHint => "j / k / g / G: 範囲拡張    y: 行コピー    Y: @参照    V / Esc: 取消",
        PreviewSelectHelp => "v: 文字範囲を選択   V: 行を選択(y でコピー)",
        HintSelect => "選択",
        StVisualLine => "行ビジュアル",
        WkAtRef => "@参照",
        WkCodeBlock => "コードブロック",
        StChangedOnly => "変更のみ",
        ChangedFilterHint => "Enter: プレビュー  n / N: 次 / 前  C / h: 全ファイル",
        NoChangedFiles => "変更ファイルはありません",
        JumpTargetHidden => "対象が隠しディレクトリ配下です(`.` で隠しファイル表示)",
        StFollow => "追尾",
        FollowOn => "追尾: ON (q で解除)",
        FollowOff => "追尾: OFF",
        FollowShowSince => "フォロー開始以降",
        FollowShowFull => "フル差分",
        HintFollowScope => "フル/開始以降",
        ChangedFilterHelp => "変更ファイルのみ表示 (git)",
        JumpChangeHelp => "次 / 前の変更ファイルへジャンプ",
        FollowHelp => "追尾モード: 外部で変更されたファイルを自動プレビュー",
        AtRefHelp => "キャレット / 選択範囲の @path#L 参照をコピー",
        PasteJumpHelp => "パス / GitHub リンクを貼り付けてその位置へ移動(reveal + preview)",
        PasteJumpNoClipboard => "クリップボードが空、または利用できません",
        PasteJumpUnrecognized => "クリップボードにパスが見つかりません",
        PasteJumpNotFound => "パスが見つかりません: ",
        HintPasteJump => "パス移動",
        HintNewTab => "別タブ",
        OpenLinkNewTabHelp => "フォーカス中のリンクを別タブで開く",
        MermaidZoomHelp => "フォーカス中の図をその場でズーム(ズーム中 hjkl=パン・0=フィット)",
        OpenInNewTabHelp => "カーソル下のエントリを別タブで開く",
        BookmarkOverwriteConfirm => "ブックマークを上書き",
        StMarkOverwrite => "上書き?",
        StMarkOverwriteHint => "y / Enter: 上書き   n / Esc: 取消",
        StRename => "リネーム",
        StRenameConfirm => "リネーム確認",
        StSearch => "検索",
        StSort => "並び替え",
        StTree => "ツリー",
        StVisual => "ビジュアル",
        HintAnchor => "アンカー",
        WkCreate => "作成",
        AgoDays => "日前",
        WkDelete => "削除",
        HintDiff => "差分",
        HintEdit => "編集",
        HintEnds => "先頭/末尾",
        HintEnter => "開く",
        HintFileOps => "ファイル操作",
        HintFilter => "絞り込み",
        HintFit => "フィット",
        WkFull => "フル",
        HintGit => "Git",
        HintBookmarks => "ブックマーク",
        HintHelp => "ヘルプ",
        HintHidden => "隠し",
        AgoHr => "時間前",
        HintHscroll => "横移動",
        HintInfo => "情報",
        HintLineEnds => "行頭/末",
        HintLink => "リンク",
        HintMark => "登録",
        HintToggle => "トグル",
        BusyGitScan => "git スキャン",
        BusyFilterScan => "ファイル走査",
        BusyMedia => "メディア読込",
        BusyHighlight => "ハイライト準備",
        BusyImages => "画像読込",
        BusyFileOp => "ファイル操作",
        FileOpBusy => "別のファイル操作を実行中です",
        BusyGitOp => "git 操作",
        GitOpBusy => "別の git 操作を実行中です",
        TaskFileChanged => "チェックボックスを切り替えられませんでした — 再読込しました",
        AgoMin => "分前",
        AgoMonths => "ヶ月前",
        WkName => "名前",
        HintOpen => "開く",
        HintPage => "ページ",
        HintFileJump => "次/前ファイル",
        PreviewFileJumpHelp => "ツリー表示順で次/前のファイルをプレビュー(端で wrap)",
        HintPan => "パン",
        WkParent => "",
        WkPaste => "貼付",
        WkDuplicate => "複製",
        HintPath => "パス",
        HintPick => "1件",
        HintQuit => "終了",
        HintCloseTab => "タブを閉じる",
        HintRawSource => "ソース表示",
        HintOutline => "アウトライン",
        HintRendered => "装飾表示",
        MdRawToggleHelp => "装飾表示 / ソース表示 を切替(ソースは選択可)",
        WkRelative => "相対",
        WkRename => "改名",
        HintSearch => "検索",
        HintSort => "並び",
        HintTab => "タブ",
        HintUp => "親へ",
        HintVisual => "範囲",
        AgoYears => "年前",
        WkCopyPathTitle => "パスをコピー",
        WkGitCopyTitle => "コミットをコピー",
        WkChangeId => "change id",
        WkCommitId => "commit id",
        WkShortHash => "短ハッシュ",
        WkFullHash => "完全ハッシュ",
        WkSubject => "件名",
        WkMessage => "メッセージ",
        WkAuthor => "著者",
        WkDate => "日付",
        NoCommitToCopy => "コピーするコミットがありません",
        ImageUnsupported => "[image] この端末では画像を表示できません、または読み込みに失敗しました",
        PreviewTruncated => "\n\n— (省略: 表示上限に達しました) —",
        VideoThumbUnavailable => {
            "[動画] サムネイル不可 — ffmpegthumbnailer か ffmpeg を導入してください(kitty graphics 対応端末が必要)"
        }
        PdfPreviewUnavailable => {
            "[PDF] 表示不可 — kitty graphics 対応端末を使ってください(または暗号化/破損した PDF です)"
        }
        ArchiveListUnavailable => {
            "[アーカイブ] 一覧化できません — 壊れたファイルか非対応形式です"
        }
        MermaidUnavailable => "[mermaid] この図は画像化できませんでした — q で戻れます",
        DiagramOpenFailed => "図が見つかりません(ファイルが変更された可能性) — プレビューを開き直してください",
        CommandOpenedExternally => "外部プログラムで開きました: ",
        CommandPreviewFailed => "外部コマンド委譲に失敗: ",
        MermaidCaption => "Enter: 全画面",
        MermaidZoomAffordance => "+/-: ズーム",
        MermaidPanAffordance => "hjkl:パン  0:フィット",
        StHelp => "ヘルプ",
        StHelpHint => "j/k:スクロール  g/G:先頭/末尾  q/Esc:閉じる",
        ExternalGitDisabled => "git 連携は無効です(設定: [external] git = false)",
        GitNotInstalled => "git が見つかりません — git 連携はオフです",
        ExternalGitToolDisabled => "外部 git ツールは無効です(設定: [external] git_tool = false)",
        ExternalOpenLinksDisabled => "リンク/ファイルを開く機能は無効です(設定: [external] open_links = false)",
        AlreadyExists => "既に存在します: ",
        TrashFailed => "ゴミ箱への移動に失敗しました",
        RenameTempExists => "一時ファイル名が既存: ",
        RenameDestExists => "リネーム先が既存: ",
        NameUnavailable => "名前の取得に失敗: ",
        RenameStageFailed => "一括リネーム(一時退避): ",
        RenameCommitFailed => "一括リネーム(確定): ",
        RollbackIncomplete => "巻き戻しにも失敗、手で片付けてください: ",
        RenameEmptyName => "空の名前になります",
        RenameSlashInName => "名前に / は使えません: ",
        RenameDestDuplicate => "リネーム先が重複: ",
    }
}

/// Return the string for key `msg` according to the language.
pub fn tr(lang: Lang, msg: Msg) -> &'static str {
    match lang {
        Lang::En => en(msg),
        Lang::Jp => jp(msg),
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn parse_defaults_to_en() {
        assert_eq!(Lang::parse(""), Lang::En);
        assert_eq!(Lang::parse("en"), Lang::En);
        assert_eq!(Lang::parse("english"), Lang::En);
        assert_eq!(Lang::parse("fr"), Lang::En, "未対応は英語");
        assert_eq!(Lang::parse("jp"), Lang::Jp);
        assert_eq!(Lang::parse("JA"), Lang::Jp);
        assert_eq!(Lang::parse(" Japanese "), Lang::Jp);
    }

    #[test]
    fn tr_selects_language() {
        assert_eq!(tr(Lang::En, Msg::GitNoBranchesItem), "  (no branches)");
        assert_eq!(tr(Lang::Jp, Msg::GitNoBranchesItem), "  (ブランチなし)");
        assert_eq!(tr(Lang::En, Msg::GitNoChangesItem), "  (no changes)");
        assert_eq!(tr(Lang::Jp, Msg::GitNoChangesItem), "  (変更なし)");
    }

    /// Both tag formats a real OS lookup can hand us must resolve the same: `sys-locale` returns
    /// BCP-47 (`ja-JP`, hyphen) on every platform, while a raw locale env var is POSIX-style
    /// (`ja_JP`, underscore) — `from_lang_tag` only looks at the leading "ja", so the separator
    /// (and any trailing `.UTF-8` encoding/`@modifier` suffix) must not matter either way.
    #[test]
    fn from_lang_tag_detects_japanese_in_either_separator_style() {
        assert_eq!(Lang::from_lang_tag("ja"), Lang::Jp);
        assert_eq!(
            Lang::from_lang_tag("ja-JP"),
            Lang::Jp,
            "BCP-47 (sys-locale)"
        );
        assert_eq!(
            Lang::from_lang_tag("ja_JP"),
            Lang::Jp,
            "POSIX-style (raw env var)"
        );
        assert_eq!(Lang::from_lang_tag("ja_JP.UTF-8"), Lang::Jp);
        assert_eq!(Lang::from_lang_tag("JA-jp"), Lang::Jp, "大文字小文字混在");
        assert_eq!(Lang::from_lang_tag("en-US"), Lang::En);
        assert_eq!(Lang::from_lang_tag("en_US.UTF-8"), Lang::En);
        assert_eq!(Lang::from_lang_tag("fr-FR"), Lang::En);
        assert_eq!(Lang::from_lang_tag("C"), Lang::En);
        assert_eq!(Lang::from_lang_tag(""), Lang::En, "空文字列");
        assert_eq!(
            Lang::from_lang_tag("not-a-locale-at-all"),
            Lang::En,
            "不正値"
        );
    }

    #[test]
    fn resolve_explicit_overrides_auto() {
        // An explicit specification passes through as-is.
        assert_eq!(Lang::resolve("jp"), Lang::Jp);
        assert_eq!(Lang::resolve("en"), Lang::En);
        // Unspecified-equivalent values (empty / auto / system) go to the OS judgment. In tests,
        // from_os is fixed to En.
        assert_eq!(Lang::resolve(""), Lang::En);
        assert_eq!(Lang::resolve("auto"), Lang::En);
        assert_eq!(Lang::resolve(" System "), Lang::En);
    }

    // Gathers every Msg variant into one array and runs **every match arm** of en()/jp() as an
    // exhaustive sweep.
    // If a new message is added but forgotten here, the coverage drop makes it noticeable (a
    // safety net separate from the compiler's exhaustiveness check).
    // Since the language gate is only allow(dead_code) (not a removed cfg), every variant can be
    // referenced under both features.
    const ALL_MSGS: &[Msg] = &[
        Msg::GitNoBranchesItem,
        Msg::GitNoWorktreesItem,
        Msg::GitWorktreesLabel,
        Msg::NoWorktrees,
        Msg::WorktreeIsBare,
        Msg::WorktreeUnavailable,
        Msg::WorktreeAlreadyCurrent,
        Msg::WorktreesNavHint,
        Msg::StWorktrees,
        Msg::StWorktreeChip,
        Msg::GitWorktreeSwitch,
        Msg::GitWorktreesRow,
        Msg::WorktreeShowChangesHelp,
        Msg::WorktreeCreateHelp,
        Msg::NewWorktree,
        Msg::CreatedWorktree,
        Msg::GitNoChangesItem,
        Msg::GitNoCommitsItem,
        Msg::BmTitle,
        Msg::DlgConfirmTitle,
        Msg::DlgDropTitle,
        Msg::HelpTitle,
        Msg::InfoTitle,
        Msg::DlgInputTitle,
        Msg::DlgRenamePreviewTitle,
        Msg::DlgDeletePermanentHint,
        Msg::DlgForceDeleteHint,
        Msg::BmEmpty,
        Msg::GitNoChanges,
        Msg::BatchRename,
        Msg::GitCommitWorktreeDetail,
        Msg::CommitMessage,
        Msg::Committed,
        Msg::Copied,
        Msg::Create,
        Msg::Created,
        Msg::CreatedBranch,
        Msg::StScrollHintCtrl,
        Msg::CutDone,
        Msg::DeleteTarget,
        Msg::DeleteBranch,
        Msg::DeletedBranch,
        Msg::DeletedPermanently,
        Msg::DiscardChangesTo,
        Msg::Discarded,
        Msg::StApplyClearHint,
        Msg::StCommitHint,
        Msg::StCreateHint,
        Msg::StRenamePreviewHint,
        Msg::StRenameHint,
        Msg::StSearchHint,
        Msg::TreeFile,
        Msg::GitBranchesLabel,
        Msg::GitChangesLabel,
        Msg::TreeGitChangesHub,
        Msg::GitGraphLabel,
        Msg::GitLogLabel,
        Msg::TreeGitStatus,
        Msg::BmGlobal,
        Msg::HelpGlobal,
        Msg::BmLocal,
        Msg::InfoModified,
        Msg::Moved,
        Msg::MovedToTrash,
        Msg::NewBranch,
        Msg::Pasted,
        Msg::Duplicated,
        Msg::InfoPerm,
        Msg::PreviewGitDiff,
        Msg::PreviewImage,
        Msg::PreviewTextMarkdown,
        Msg::Rename,
        Msg::Renamed,
        Msg::TreeSelection,
        Msg::InfoSize,
        Msg::StPagerSpaceHint,
        Msg::Staged,
        Msg::StagedAll,
        Msg::SwitchedTo,
        Msg::HelpTabs,
        Msg::InfoTarget,
        Msg::TreeSection,
        Msg::InfoType,
        Msg::UncommittedChanges,
        Msg::Unstaged,
        Msg::UnstagedAll,
        Msg::Highlighting,
        Msg::ScrollTop,
        Msg::ScrollBot,
        Msg::ScrollAll,
        Msg::StSortHint,
        Msg::StPathAbs,
        Msg::TreeAddedStaged,
        Msg::AlreadyAtStartDir,
        Msg::AlreadyRoot,
        Msg::AnchorReset,
        Msg::TreeAnchorRoot,
        Msg::GitBack,
        Msg::BackToGitView,
        Msg::BackToChanges,
        Msg::BackToTree,
        Msg::TreeBookmarkHint,
        Msg::PreviewBookmarkHint,
        Msg::BookmarkTargetMissing,
        Msg::Bookmarked,
        Msg::GitBranches,
        Msg::DlgCopyKey,
        Msg::StCopyMoveHint,
        Msg::CantCloseLastTab,
        Msg::Canceled,
        Msg::CannotDeleteCurrentBranch,
        Msg::CannotEditDirectory,
        Msg::CannotPasteIntoSelf,
        Msg::GitCheckout,
        Msg::ClipboardEmpty,
        Msg::GitCloseView,
        Msg::GitCommit,
        Msg::GitCommitDetail,
        Msg::CopiedPrefix,
        Msg::WatchFailedPrefix,
        Msg::CopyHint,
        Msg::CopyFailed,
        Msg::CopiedCodeBlock,
        Msg::HintCopyCode,
        Msg::CutHint,
        Msg::CyclePathStyle,
        Msg::GitDelete,
        Msg::TreeDeleted,
        Msg::GitDetail,
        Msg::GitDiffAll,
        Msg::TreeDiffFile,
        Msg::DiffAuto,
        Msg::DiffSideBySide,
        Msg::DiffUnified,
        Msg::InfoDirectory,
        Msg::GitDiscardFile,
        Msg::DiscardWholeFile,
        Msg::TreeDragDrop,
        Msg::TreeDropFiles,
        Msg::DroppedItems,
        Msg::EditExternal,
        Msg::EditExternalEnv,
        Msg::EditorFailed,
        Msg::EnterDirectory,
        Msg::Etc,
        Msg::ExpandInPlace,
        Msg::GitExternalTool,
        Msg::Failed,
        Msg::InfoFile,
        Msg::GitFileDiff,
        Msg::TreeFileInfo,
        Msg::TreeFilter,
        Msg::GitFilterByName,
        Msg::FocusMdLink,
        Msg::MdTaskToggleHelp,
        Msg::HintDetailsToggle,
        Msg::GitToolFailed,
        Msg::JjToolFailed,
        Msg::JjChangesLabel,
        Msg::JjGraphLabel,
        Msg::JjCloseView,
        Msg::JjDiffAll,
        Msg::JjBookmarksRow,
        Msg::JjExternalTool,
        Msg::JjSyncRow,
        Msg::JjGraphAllRow,
        Msg::JjWorkspacesUnlisted,
        Msg::JjSyncConfirm,
        Msg::JjSyncDone,
        Msg::JjSyncFailed,
        Msg::JjSyncNotJj,
        Msg::GlobalApp,
        Msg::HScroll,
        Msg::GitHScrollEnds,
        Msg::StCloseHint,
        Msg::InfoClose,
        Msg::AnchorNotFound,
        Msg::OutlineEmpty,
        Msg::InvalidMarkKey,
        Msg::Items,
        Msg::InfoItems,
        Msg::VisualOpsHint,
        Msg::BranchesNavHint,
        Msg::GitNavDetailHint,
        Msg::GitNavDetailCommitHint,
        Msg::GraphBaseSet,
        Msg::GraphBaseCleared,
        Msg::GraphBaseNeedsCommit,
        Msg::GraphSetBaseHelp,
        Msg::GraphClearBaseHelp,
        Msg::GraphBranchesHelp,
        Msg::GraphLegendHidden,
        Msg::GraphPickerTitle,
        Msg::GraphPickerFooter,
        Msg::GraphPickerHeadLocked,
        Msg::DiffScrollHint,
        Msg::DiffScrollDiscardHint,
        Msg::HelpJumpTab,
        Msg::JustNow,
        Msg::Keymap,
        Msg::GitLayout,
        Msg::LineStartEnd,
        Msg::ListingStale,
        Msg::StListingStale,
        Msg::Loading,
        Msg::Local,
        Msg::GitLogGraph,
        Msg::DlgMove,
        Msg::MarkHint,
        Msg::Match,
        Msg::MessageEmpty,
        Msg::TreeModified,
        Msg::GitMove,
        Msg::GitMoveCommit,
        Msg::TreeMoveUpDown,
        Msg::DlgCancel,
        Msg::NameEmpty,
        Msg::GitNewBranch,
        Msg::HelpNewTab,
        Msg::NoBookmark,
        Msg::NoBranches,
        Msg::NoChanges,
        Msg::NoCommits,
        Msg::NoCopyTarget,
        Msg::NoFileToEdit,
        Msg::NoMatch,
        Msg::NoTarget,
        Msg::NotAFile,
        Msg::NotAGitRepo,
        Msg::NotFound,
        Msg::NothingStaged,
        Msg::OpenFailed,
        Msg::OpenLinkHint,
        Msg::Opened,
        Msg::OperationFailed,
        Msg::PanHint,
        Msg::PathLabel,
        Msg::PrevNextTab,
        Msg::Quit,
        Msg::Refresh,
        Msg::RelLabel,
        Msg::TreeStatusRenamed,
        Msg::ResetRoot,
        Msg::ResetFit,
        Msg::Root,
        Msg::StGitHubKeys,
        Msg::Scroll,
        Msg::Scroll10Lines,
        Msg::SearchHint,
        Msg::SearchCodeTextOnly,
        Msg::TableSearchHelp,
        Msg::SelLabel,
        Msg::SortHint,
        Msg::StageHint,
        Msg::Symlink,
        Msg::ToParent,
        Msg::ToggleHidden,
        Msg::ToggleOne,
        Msg::ToggleHelp,
        Msg::TopBottom,
        Msg::TrailingSlashFolder,
        Msg::UnstageHint,
        Msg::Untracked,
        Msg::VisualRangeHint,
        Msg::DlgTrash,
        Msg::DlgApply,
        Msg::DlgDeleteSafe,
        Msg::DlgYesNo,
        Msg::StTrashDelete,
        Msg::StApply,
        Msg::StDeleteForce,
        Msg::Zoom,
        Msg::BmActions,
        Msg::Empty,
        Msg::StBatchRename,
        Msg::StBookmarks,
        Msg::StTabs,
        Msg::StOutline,
        Msg::TabsTitle,
        Msg::TabsActions,
        Msg::OutlineTitle,
        Msg::OutlineActions,
        Msg::HelpTabList,
        Msg::StBranch,
        Msg::StChanges,
        Msg::StCommit,
        Msg::StCommitDiff,
        Msg::StCreate,
        Msg::StDelete,
        Msg::StDiff,
        Msg::StDrop,
        Msg::StFilter,
        Msg::DiffScrollNoDiscardHint,
        Msg::StJjHubKeys,
        Msg::BookmarksNavHint,
        Msg::JjGraphNavHint,
        Msg::GraphAlreadyAll,
        Msg::GraphShowingAll,
        Msg::GraphShowingDefault,
        Msg::StBookmark,
        Msg::VcsReadOnly,
        Msg::StGit,
        Msg::StJj,
        Msg::StGraph,
        Msg::StImage,
        Msg::StInfo,
        Msg::StLog,
        Msg::StMark,
        Msg::StPreview,
        Msg::StRename,
        Msg::StRenameConfirm,
        Msg::StSearch,
        Msg::StSort,
        Msg::StTree,
        Msg::StVisual,
        Msg::HintAnchor,
        Msg::WkCreate,
        Msg::AgoDays,
        Msg::WkDelete,
        Msg::HintDiff,
        Msg::HintEdit,
        Msg::HintEnds,
        Msg::HintEnter,
        Msg::HintFileOps,
        Msg::HintFilter,
        Msg::HintFit,
        Msg::WkFull,
        Msg::HintGit,
        Msg::HintBookmarks,
        Msg::HintHelp,
        Msg::HintHidden,
        Msg::AgoHr,
        Msg::HintHscroll,
        Msg::HintInfo,
        Msg::HintLineEnds,
        Msg::HintLink,
        Msg::HintMark,
        Msg::HintToggle,
        Msg::BusyGitScan,
        Msg::BusyFilterScan,
        Msg::BusyMedia,
        Msg::BusyHighlight,
        Msg::BusyImages,
        Msg::BusyFileOp,
        Msg::FileOpBusy,
        Msg::BusyGitOp,
        Msg::GitOpBusy,
        Msg::TaskFileChanged,
        Msg::AgoMin,
        Msg::AgoMonths,
        Msg::WkName,
        Msg::HintOpen,
        Msg::HintPage,
        Msg::HintFileJump,
        Msg::PreviewFileJumpHelp,
        Msg::HintPan,
        Msg::WkParent,
        Msg::WkPaste,
        Msg::WkDuplicate,
        Msg::HintPath,
        Msg::HintPick,
        Msg::HintQuit,
        Msg::HintCloseTab,
        Msg::HintRawSource,
        Msg::HintOutline,
        Msg::HintRendered,
        Msg::MdRawToggleHelp,
        Msg::QuitOrCloseTab,
        Msg::WkRelative,
        Msg::WkRename,
        Msg::HintSearch,
        Msg::HintSort,
        Msg::HintTab,
        Msg::HintUp,
        Msg::HintVisual,
        Msg::AgoYears,
        Msg::WkCopyPathTitle,
        Msg::StTable,
        Msg::PreviewTable,
        Msg::WkTableCopyTitle,
        Msg::WkCell,
        Msg::WkRow,
        Msg::WkColumn,
        Msg::HintCell,
        Msg::TableMoveHelp,
        Msg::TableColsHelp,
        Msg::StTableCell,
        Msg::TableCellTitle,
        Msg::TableCellActions,
        Msg::HintViewCell,
        Msg::TableCellViewHelp,
        Msg::TableCellEmpty,
        Msg::PreviewVisualHint,
        Msg::PreviewVisualLineHint,
        Msg::PreviewSelectHelp,
        Msg::HintSelect,
        Msg::StVisualLine,
        Msg::WkAtRef,
        Msg::WkCodeBlock,
        Msg::StChangedOnly,
        Msg::ChangedFilterHint,
        Msg::NoChangedFiles,
        Msg::JumpTargetHidden,
        Msg::StFollow,
        Msg::FollowOn,
        Msg::FollowOff,
        Msg::FollowShowSince,
        Msg::FollowShowFull,
        Msg::HintFollowScope,
        Msg::ChangedFilterHelp,
        Msg::JumpChangeHelp,
        Msg::FollowHelp,
        Msg::AtRefHelp,
        Msg::PasteJumpHelp,
        Msg::PasteJumpNoClipboard,
        Msg::PasteJumpUnrecognized,
        Msg::PasteJumpNotFound,
        Msg::HintPasteJump,
        Msg::HintNewTab,
        Msg::OpenLinkNewTabHelp,
        Msg::MermaidZoomHelp,
        Msg::OpenInNewTabHelp,
        Msg::BookmarkOverwriteConfirm,
        Msg::StMarkOverwrite,
        Msg::StMarkOverwriteHint,
        Msg::WkGitCopyTitle,
        Msg::WkChangeId,
        Msg::WkCommitId,
        Msg::WkShortHash,
        Msg::WkFullHash,
        Msg::WkSubject,
        Msg::WkMessage,
        Msg::WkAuthor,
        Msg::WkDate,
        Msg::NoCommitToCopy,
        Msg::ImageUnsupported,
        Msg::PreviewTruncated,
        Msg::VideoThumbUnavailable,
        Msg::PdfPreviewUnavailable,
        Msg::ArchiveListUnavailable,
        Msg::MermaidUnavailable,
        Msg::DiagramOpenFailed,
        Msg::CommandOpenedExternally,
        Msg::CommandPreviewFailed,
        Msg::MermaidCaption,
        Msg::MermaidZoomAffordance,
        Msg::MermaidPanAffordance,
        Msg::QuitConfirm,
        Msg::QuitWhileFileOp,
        Msg::QuitWhileGitOp,
        Msg::StQuit,
        Msg::StQuitHint,
        Msg::StHelp,
        Msg::StHelpHint,
        Msg::ExternalGitDisabled,
        Msg::GitNotInstalled,
        Msg::ExternalGitToolDisabled,
        Msg::ExternalOpenLinksDisabled,
        Msg::AlreadyExists,
        Msg::TrashFailed,
        Msg::RenameTempExists,
        Msg::RenameDestExists,
        Msg::NameUnavailable,
        Msg::RenameStageFailed,
        Msg::RenameCommitFailed,
        Msg::RollbackIncomplete,
        Msg::RenameEmptyName,
        Msg::RenameSlashInName,
        Msg::RenameDestDuplicate,
    ];

    #[test]
    fn every_message_has_text_in_both_languages() {
        // Empty is intentionally an empty string (both languages ""). Everything else must be
        // non-empty in both en/jp.
        for &m in ALL_MSGS {
            let en = tr(Lang::En, m);
            let jp = tr(Lang::Jp, m);
            if m == Msg::Empty {
                assert_eq!(en, "", "Empty は en で空文字のはず");
                assert_eq!(jp, "", "Empty は jp で空文字のはず");
            } else {
                assert!(!en.is_empty(), "{m:?} の en 文言が空");
                assert!(!jp.is_empty(), "{m:?} の jp 文言が空");
            }
        }
    }

    #[test]
    fn message_catalog_is_unique_and_mostly_translated() {
        // No duplicate variant in the array (catches copy-paste accidents). Since Msg doesn't
        // implement Hash, check via a naive all-pairs comparison.
        for (i, &a) in ALL_MSGS.iter().enumerate() {
            for &b in &ALL_MSGS[i + 1..] {
                assert_ne!(a, b, "ALL_MSGS に重複 variant がある: {a:?}");
            }
        }
        // A majority of variants have different strings in English and Japanese (some, like the
        // Git proper noun, match, but most differ).
        let differ = ALL_MSGS
            .iter()
            .filter(|&&m| tr(Lang::En, m) != tr(Lang::Jp, m))
            .count();
        assert!(
            differ > ALL_MSGS.len() / 2,
            "英日で異なる文言が過半数のはず: {differ}/{}",
            ALL_MSGS.len()
        );
    }

    /// Extract every `Msg` variant name directly from this file's own enum declaration (`pub enum
    /// Msg { ... }`) — the same self-scanning trick `e2e_tests.rs`'s `extract_ui_config_field_names`
    /// uses for `UiConfig`. Brace-match the body, then keep only lines that are neither blank, a
    /// comment (`//`/`///` — both start with `//`), nor an attribute (`#[...]`, e.g. the
    /// `#[cfg_attr(not(feature = "git"), allow(dead_code))]` lines above the git-copy-only
    /// variants), and take the identifier up to the first non-identifier character. Every `Msg`
    /// variant is a plain unit variant (confirmed above: `ALL_MSGS` never writes a `(...)`/`{...}`
    /// payload on one), so "identifier up to the first non-identifier char" is the whole variant
    /// name, with no destructuring to worry about.
    ///
    /// This exists because `en()`/`jp()` being *exhaustive* matches only proves a translation exists
    /// for every variant — it says nothing about whether anything ever runs
    /// `every_message_has_text_in_both_languages` / `message_catalog_is_unique_and_mostly_translated`
    /// *against* that variant, since both sweeps iterate `ALL_MSGS`, a hand-maintained array that a
    /// new variant is never forced to join. `Msg` variant count and `ALL_MSGS.len()` happen to both
    /// be 440 right now — perfect agreement that this test turns into a guarantee instead of a
    /// coincidence.
    fn extract_msg_variant_names() -> Vec<String> {
        let src = include_str!("i18n.rs");
        let marker = "pub enum Msg {";
        let start = src
            .find(marker)
            .expect("Msg enum not found in i18n.rs — did it move or get renamed?");
        let body_start = start + marker.len() - 1; // the opening '{' itself
        let bytes = src.as_bytes();
        let mut depth = 0i32;
        let mut end = body_start;
        for (i, &b) in bytes[body_start..].iter().enumerate() {
            match b {
                b'{' => depth += 1,
                b'}' => {
                    depth -= 1;
                    if depth == 0 {
                        end = body_start + i;
                        break;
                    }
                }
                _ => {}
            }
        }
        assert!(end > body_start, "matching closing brace not found");
        let body = &src[body_start..end];
        let mut names = Vec::new();
        for line in body.lines() {
            let t = line.trim();
            if t.is_empty() || t.starts_with("//") || t.starts_with('#') {
                continue;
            }
            let ident_end = t
                .find(|c: char| !(c.is_alphanumeric() || c == '_'))
                .unwrap_or(t.len());
            if ident_end > 0 {
                names.push(t[..ident_end].to_string());
            }
        }
        names
    }

    /// Safety valve for the extractor above: if the brace/line scan ever breaks (the enum
    /// reformatted in a way it can't follow), it must fail LOUD by finding too few variants — not
    /// silently return an empty/tiny list that would make `all_msg_variants_are_covered_by_all_msgs`
    /// below vacuously pass. `Msg` currently has 440 variants; 300 is a conservative floor that still
    /// catches "extraction basically broke" while tolerating future variant removals.
    #[test]
    fn msg_variant_extraction_finds_at_least_300_variants() {
        let names = extract_msg_variant_names();
        assert!(
            names.len() >= 300,
            "抽出数が少なすぎる(安全弁): {} 件 — パーサが壊れている可能性: 先頭5件={:?}",
            names.len(),
            &names[..names.len().min(5)]
        );
    }

    /// Completeness: every `Msg` variant the enum actually declares must appear in `ALL_MSGS`
    /// (otherwise a new variant silently never joins the `every_message_has_text_in_both_languages`
    /// / `message_catalog_is_unique_and_mostly_translated` sweeps above), and vice versa (no stale
    /// `ALL_MSGS` entry left over from a removed/renamed variant, which would silently test nothing
    /// real). Add a variant to `Msg` without adding it to `ALL_MSGS` → this fails and names exactly
    /// which one is missing.
    #[test]
    fn all_msg_variants_are_covered_by_all_msgs() {
        let extracted = extract_msg_variant_names();
        assert!(
            extracted.len() >= 300,
            "抽出数が少なすぎる(安全弁): {} 件",
            extracted.len()
        );
        let extracted_set: std::collections::BTreeSet<&str> =
            extracted.iter().map(|s| s.as_str()).collect();
        // `ALL_MSGS` holds `Msg` values, not strings — `Msg` derives `Debug`, and for a fieldless
        // (unit) variant that always renders exactly its identifier, so this reuses the same
        // "identifier as a string" shape as `extracted` without maintaining a second by-hand list.
        let table_names: Vec<String> = ALL_MSGS.iter().map(|m| format!("{m:?}")).collect();
        let table_set: std::collections::BTreeSet<&str> =
            table_names.iter().map(|s| s.as_str()).collect();
        let missing_from_all_msgs: Vec<&&str> = extracted_set.difference(&table_set).collect();
        let stale_in_all_msgs: Vec<&&str> = table_set.difference(&extracted_set).collect();
        assert!(
            missing_from_all_msgs.is_empty() && stale_in_all_msgs.is_empty(),
            "enum Msg と ALL_MSGS が不一致。\n\
             ALL_MSGS に無い(新規 variant を追加し忘れ?): {missing_from_all_msgs:?}\n\
             enum に無い(削除/改名後の古いエントリ?): {stale_in_all_msgs:?}"
        );
        // No duplicate entries in ALL_MSGS either
        // (`message_catalog_is_unique_and_mostly_translated` above already checks this via an
        // all-pairs `assert_ne!` loop; this set-size comparison is a cheap second, independent proof
        // that keeps holding even if that loop is ever weakened).
        assert_eq!(
            table_set.len(),
            ALL_MSGS.len(),
            "ALL_MSGS に重複 variant がある"
        );
    }
}