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
//! Localization: every player-facing string, in English, French, German,
//! Spanish, Italian, Dutch, Russian, and Japanese.
//!
//! One [`Tr`] table per language; a missing translation is a compile error.
//! Parameterized strings carry `{x}` markers, filled at the call site by
//! [`fill`] - which is the only way they are filled, so a template with two
//! markers reads as one call rather than a chain of replacements. Every
//! translated voice is informal (tu / du / tú / tu /
//! je / ты, and Japanese's plain friendly register), since the game is
//! for kids as much as anyone.
/// A supported UI language. Persisted in settings.txt by its `key`.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
pub enum Lang {
#[default]
En,
Fr,
De,
Es,
It,
Nl,
Ru,
Ja,
}
pub const ALL_LANGS: [Lang; 8] = [
Lang::En,
Lang::Fr,
Lang::De,
Lang::Es,
Lang::It,
Lang::Nl,
Lang::Ru,
Lang::Ja,
];
impl crate::app::cycle::Cycle for Lang {
const VARIANTS: &'static [Self] = &ALL_LANGS;
}
/// Fill a template's `{marker}`s. `fill(tr.wins, &[("p", "2")])`.
pub fn fill(template: &str, args: &[(&str, &str)]) -> String {
let mut out = template.to_string();
for (key, value) in args {
out = out.replace(&format!("{{{key}}}"), value);
}
out
}
impl Lang {
pub fn tr(self) -> &'static Tr {
match self {
Lang::En => &EN,
Lang::Fr => &FR,
Lang::De => &DE,
Lang::Es => &ES,
Lang::It => &IT,
Lang::Nl => &NL,
Lang::Ru => &RU,
Lang::Ja => &JA,
}
}
/// Stable settings-file key.
pub fn key(self) -> &'static str {
match self {
Lang::En => "en",
Lang::Fr => "fr",
Lang::De => "de",
Lang::Es => "es",
Lang::It => "it",
Lang::Nl => "nl",
Lang::Ru => "ru",
Lang::Ja => "ja",
}
}
pub fn from_key(key: &str) -> Lang {
match key {
"fr" => Lang::Fr,
"de" => Lang::De,
"es" => Lang::Es,
"it" => Lang::It,
"nl" => Lang::Nl,
"ru" => Lang::Ru,
"ja" => Lang::Ja,
_ => Lang::En,
}
}
/// The language's own name, shown in the settings row.
pub fn native_name(self) -> &'static str {
match self {
Lang::En => "English",
Lang::Fr => "Français",
Lang::De => "Deutsch",
Lang::Es => "Español",
Lang::It => "Italiano",
Lang::Nl => "Nederlands",
Lang::Ru => "Русский",
Lang::Ja => "日本語",
}
}
/// This language's column in the level tables, English first. Both
/// tables order their columns this way, so the order lives here once
/// rather than being counted out again at each lookup.
fn column(self) -> usize {
match self {
Lang::En => 0,
Lang::Fr => 1,
Lang::De => 2,
Lang::Es => 3,
Lang::It => 4,
Lang::Nl => 5,
Lang::Ru => 6,
Lang::Ja => 7,
}
}
/// Teaching hint for a shipped level, if it has one. Column 0 is the
/// English name the row is keyed by, so the hints sit one place further
/// along. Keyed by name alone, so a level on a list is asked about
/// through [`crate::app::Campaign::hint`], which knows which levels
/// are shipped ones.
pub fn level_hint(self, en_name: &str) -> Option<&'static str> {
LEVEL_HINTS
.iter()
.find(|row| row[0] == en_name)
.map(|row| row[1 + self.column()])
}
/// Localized name for a built-in level; other names pass through.
/// English is both the key and its own translation, so it needs no
/// lookup at all. A player's level can share a shipped one's name, so
/// a level on a list is named through
/// [`crate::app::Campaign::shown_name`], which only asks this for the
/// shipped ones.
pub fn level_name(self, en: &str) -> &str {
if self == Lang::En {
return en;
}
LEVEL_NAMES
.iter()
.find(|row| row[0] == en)
.map_or(en, |row| row[self.column()])
}
}
/// Declares [`Tr`], and with it a way to walk every string it holds.
///
/// The walk is generated from the same field list as the struct, so a string
/// added here is checked by `placeholders_agree_across_languages` the moment
/// it is declared: there is no second list to keep in step.
macro_rules! string_table {
(
$(#[$table_meta:meta])*
struct $table:ident {
$( $(#[$field_meta:meta])* pub $field:ident : $ty:ty, )*
}
) => {
$(#[$table_meta])*
pub struct $table {
$( $(#[$field_meta])* pub $field: $ty, )*
}
impl $table {
/// Every string in the table, each paired with the field it came
/// from. Array fields expand to one entry per element.
#[cfg(test)]
pub(crate) fn strings(&self) -> Vec<(String, &'static str)> {
let mut out = Vec::new();
$( TableField::push(&self.$field, stringify!($field), &mut out); )*
out
}
}
};
}
/// A field of [`Tr`]: one string, or a fixed array of them.
#[cfg(test)]
trait TableField {
fn push(&self, field: &str, out: &mut Vec<(String, &'static str)>);
}
#[cfg(test)]
impl TableField for &'static str {
fn push(&self, field: &str, out: &mut Vec<(String, &'static str)>) {
out.push((field.to_string(), self));
}
}
#[cfg(test)]
impl<const N: usize> TableField for [&'static str; N] {
fn push(&self, field: &str, out: &mut Vec<(String, &'static str)>) {
for (index, string) in self.iter().enumerate() {
out.push((format!("{field}[{index}]"), string));
}
}
}
string_table! {
/// Every user-facing string. Grouped by screen; `{x}` markers are filled at
/// the call site.
struct Tr {
// Menu
pub tagline: &'static str,
pub menu_names: [&'static str; 9],
pub menu_blurbs: [&'static str; 9],
/// The daily row's blurb, which names the day it is offering.
pub menu_daily_blurb: &'static str,
pub menu_prompt: &'static str,
pub title_achievements: &'static str,
pub ach_names: [&'static str; 50],
pub ach_descs: [&'static str; 50],
pub stats_footer: &'static str,
pub daily_best: &'static str,
/// Field-guide names for the six crab kinds, spawn-mix order.
pub crab_names: [&'static str; 6],
/// One-word traits shown beside the value ("fast", "lure!", ...).
pub crab_notes: [&'static str; 6],
// The first-boot language picker
/// The screen the game opens on the very first run, before any
/// settings file exists. Every line of it is written in the language
/// the cursor is resting on, so the player reads the one they want and
/// stops there.
pub title_pick_language: &'static str,
/// Header and prompt of the new-version page.
pub title_new_version: &'static str,
pub prompt_new_version: &'static str,
pub prompt_pick_language: &'static str,
/// Said under the header. A first screen that looks like a decision
/// is a first screen people hesitate over; this one is not.
pub pick_language_later: &'static str,
// Mode titles
pub title_tide_pool: &'static str,
pub title_beach_day: &'static str,
pub title_turf_war: &'static str,
pub title_replay: &'static str,
pub title_online: &'static str,
pub title_vs_ai: &'static str,
pub title_editor: &'static str,
pub title_playtest: &'static str,
pub title_lobby: &'static str,
pub title_settings: &'static str,
pub title_match_setup: &'static str,
// The replay library
pub title_replays: &'static str,
pub prompt_replays: &'static str,
pub replays_empty: &'static str,
/// The heading over the shelf of kept rounds.
pub replays_heading: &'static str,
/// Playback speed readout, e.g. "x2".
pub replay_speed: &'static str,
/// The two states on the replay transport bar.
pub replay_playing: &'static str,
pub replay_paused: &'static str,
/// The transport line under a recording being watched.
pub prompt_replay_transport: &'static str,
// The stuck-player hint
pub hint_offer: &'static str,
pub hint_showing: &'static str,
// Stage select
pub title_stages: &'static str,
pub prompt_stages: &'static str,
/// The Tide Pool stage list's prompt, which offers co-op; Beach Day,
/// whose rule has no shared pool to offer, keeps `prompt_stages`.
pub prompt_stages_tide: &'static str,
/// Said on the stage list while co-op is on.
pub stage_coop_on: &'static str,
pub stage_progress: &'static str,
/// The label in front of the difficulty key under the grid.
pub stage_key: &'static str,
/// Names the shelf of levels the player built, both over their rows on
/// the grid and in front of their number in the caption.
pub stage_custom: &'static str,
/// The count over the trophy grid, same shape as [`Tr::stage_progress`].
pub ach_progress: &'static str,
pub stage_cleared: &'static str,
pub stage_open: &'static str,
pub stage_free: &'static str,
pub stage_locked: &'static str,
pub team_banner: &'static str,
// Status line
pub the_gulls: &'static str,
pub tide_event: &'static str,
/// Shown for the first moments of a lure: names the trigger.
pub lure_started: &'static str,
/// Shown for the rest of the lure: live countdown.
pub lure_banner: &'static str,
pub desync: &'static str,
pub waiting_peer: &'static str,
/// The round has stopped because one seat's input has not arrived.
/// Lockstep runs a frame only when every seat has spoken, so a still
/// picture is somebody else's trouble, and the table is told whose.
pub waiting_for: &'static str,
pub saved_count: &'static str,
pub signposts_count: &'static str,
// Puzzle goals
pub goal_bank: &'static str,
pub goal_survive: &'static str,
pub goal_golden: &'static str,
// Prompts
pub prompt_setup: &'static str,
/// The setup prompt in co-op: both players' keys, one line.
pub prompt_setup_coop: &'static str,
pub prompt_setup_full: &'static str,
/// Shown for a moment when a placement is refused because the level's
/// signposts are all out, which every other refusal is not.
pub denied_no_posts: &'static str,
pub prompt_setup_no_posts: &'static str,
pub prompt_running: &'static str,
pub prompt_won: &'static str,
/// The won prompt for a stage whose goal lets crabs go (bank a number,
/// bank the golden one), where "all crabs safe" is not what happened.
pub prompt_won_goal: &'static str,
pub prompt_lost: &'static str,
pub prompt_versus_short: &'static str,
pub prompt_versus_local: &'static str,
/// Shown instead of the key legend once the player has rebound keys.
pub prompt_setup_custom: &'static str,
pub prompt_versus_custom: &'static str,
pub prompt_enter_menu: &'static str,
/// The way off an online results card: the whole table returns to the
/// lobby it was formed in, still connected.
pub prompt_enter_lobby: &'static str,
/// The way out for somebody who is only watching a round: Escape
/// opens their own card, since a spectator cannot pause a table it is
/// not playing at, and Enter does nothing at all.
pub prompt_esc_menu: &'static str,
/// The trophy shelf: it scrolls now that it is longer than the screen,
/// so its prompt says so rather than only how to leave. The last reader
/// of the old read-out-only `prompt_esc_menu`, which went with it.
pub prompt_achievements: &'static str,
/// The music toggle, added to every play screen's prompt.
pub prompt_mute: &'static str,
/// How a kept round with no winner reads in the library. The file name
/// says "draw" in English on every machine; this is the reading of it.
pub replay_draw: &'static str,
pub pause_title: &'static str,
/// The same card's title for a spectator, whose match does not stop.
pub pause_menu_title: &'static str,
pub pause_continue: &'static str,
pub pause_to_menu: &'static str,
pub pause_quit: &'static str,
/// The prompt line while the pause card has the keyboard: its keys,
/// not the beach's.
pub prompt_paused: &'static str,
/// The heading on the spectators' event list, and the two lines their prompt
/// carries: the offer to call one, and the wait after it has.
pub spectator_call_title: &'static str,
pub spectator_call_hint: &'static str,
pub spectator_called: &'static str,
/// What the crowd is told while a vote runs: how long is left to join
/// one, and how long until the next may be called. Both in seconds.
pub spectator_vote_open: &'static str,
pub spectator_wait: &'static str,
/// How many are watching, said to the whole table so a called event
/// is not the first anyone hears of a crowd.
pub spectator_count: &'static str,
/// The heading over the seats a spectator can call to win.
pub spectator_pick_title: &'static str,
/// The spectator's prompt while the calls are open, `{n}` seconds left.
pub spectator_pick_hint: &'static str,
/// The same once a call is made: `{p}` whom, `{n}` seconds left to change it.
pub spectator_picked: &'static str,
/// The crowd's calls, `{l}` the list ("Maya ×2 · Theo ×1"): said to the
/// feed as the calls close, and on the results card.
pub crowd_picked: &'static str,
/// A spectator's call came in: `{a}` right of `{b}` made this session.
pub call_right: &'static str,
/// It did not: `{p}` whom they called, then the same record.
pub call_wrong: &'static str,
/// Said on the versus screen when a round is copied as a code.
pub round_copied: &'static str,
pub round_code_bad: &'static str,
// The new-version page (see `app::update`)
/// Headline naming the newer release, `{v}` its version.
pub update_title: &'static str,
/// The line under it naming the version being played.
pub update_have: &'static str,
/// Stands in for the release notes when the release has none.
pub update_no_notes: &'static str,
/// The question, and its two answers: open the release page, or not
/// now.
pub update_question: &'static str,
pub update_yes: &'static str,
pub update_no: &'static str,
/// Under the card: the asking can be turned off.
pub update_note: &'static str,
/// Menu notices after a yes: the browser took it, or there was no
/// browser to give it to and here is the address instead.
pub update_opened: &'static str,
pub update_open_failed: &'static str,
pub prompt_settings: &'static str,
pub prompt_match_setup: &'static str,
/// The same line with the cursor on a name row, where Enter types a
/// name rather than starting the match.
pub prompt_match_name: &'static str,
/// Short seat label: "P1" / "J1" / "S1".
pub player_label: &'static str,
// Tide events
pub events: [&'static str; 9],
/// What each event actually does, in event order: the line under the
/// headline on the centre-screen announcement.
pub event_blurbs: [&'static str; 9],
// Centre-screen announcements
pub ann_lure: &'static str,
pub ann_lure_sub: &'static str,
pub ann_surge: &'static str,
pub ann_surge_sub: &'static str,
/// A called golden crab is about to come out of a spawner hole.
pub ann_golden: &'static str,
/// Under it; `{n}` is what the crab is worth.
pub ann_golden_sub: &'static str,
// Results
pub tide_is_in: &'static str,
pub wins: &'static str,
pub dead_heat: &'static str,
/// "{t} wins!", where {t} is the team named by its members.
pub team_wins: &'static str,
pub tag_you: &'static str,
pub tag_ai: &'static str,
pub haul: &'static str,
/// The round's awards under the standings (`app::awards`). `{p}` is
/// who, one name or several joined by " & " on a tie; `{n}` the figure.
/// The round winner who was furthest behind the leader, and by how much.
pub award_comeback: &'static str,
/// The most banked during one of your own lures.
pub award_lure: &'static str,
/// The most arrows planted.
pub award_arrows: &'static str,
/// The most banked score lost, to gulls or to the left claw.
pub award_hit: &'static str,
/// Where the round's highlight reel was written.
pub highlight_saved: &'static str,
pub all_safe: &'static str,
/// The won card's headline for the same stages as `prompt_won_goal`.
pub goal_met: &'static str,
/// The heading over the puzzle loss card: the run is over, and the
/// board held under it says where.
pub crabs_lost: &'static str,
pub last_level: &'static str,
/// The heading over the last level's card: the run is finished, not
/// merely another level won.
pub campaign_done: &'static str,
// Settings rows
/// Headings on the settings card.
pub set_group_controls: &'static str,
pub set_group_sound: &'static str,
pub set_group_round: &'static str,
pub set_group_look: &'static str,
pub set_group_danger: &'static str,
/// The game itself, as distinct from any round of it: the update check.
pub set_group_game: &'static str,
/// "P{n} controls" and the three answers it can give.
pub set_seat_input: &'static str,
pub val_input_auto: &'static str,
pub val_input_keys: &'static str,
pub val_input_pad: &'static str,
pub set_commit_keys: &'static str,
pub set_repeat_delay: &'static str,
pub set_repeat_rate: &'static str,
pub set_music_on: &'static str,
pub set_music: &'static str,
pub set_sfx_on: &'static str,
pub set_sfx: &'static str,
pub set_speed: &'static str,
pub set_versus_mode: &'static str,
pub set_language: &'static str,
pub set_keyboard: &'static str,
pub set_rumble: &'static str,
pub set_deadzone: &'static str,
pub set_palette: &'static str,
/// Settings row: borderless fullscreen or a window.
pub set_fullscreen: &'static str,
pub set_ui_scale: &'static str,
pub set_reduced_motion: &'static str,
/// Settings row: whether start-up asks GitHub for a newer release.
pub set_update_check: &'static str,
/// Settings row: how many finished rounds the shelf keeps.
pub set_replay_cap: &'static str,
pub set_key_bindings: &'static str,
pub set_reset_progress: &'static str,
pub val_palette_classic: &'static str,
pub val_palette_safe: &'static str,
pub val_open: &'static str,
/// The keyboard row's "work it out yourself".
pub val_auto: &'static str,
/// The reset row's three states: offering, awaiting the second press,
/// and done.
pub val_reset: &'static str,
pub val_reset_confirm: &'static str,
pub val_reset_done: &'static str,
// Key-binding screen
pub title_controls: &'static str,
pub prompt_controls: &'static str,
pub ctl_seat: &'static str,
/// Headings on the key-binding card.
pub ctl_group_seat: &'static str,
pub ctl_group_move: &'static str,
pub ctl_group_place: &'static str,
pub ctl_group_posts: &'static str,
/// The key column while a row is listening for a keypress.
pub ctl_listening: &'static str,
/// The key column on the reset row, which is a door not a binding.
pub ctl_reset_key: &'static str,
pub ctl_press_key: &'static str,
pub ctl_taken: &'static str,
pub ctl_reset: &'static str,
/// One label per bindable action, in `binds::Action::ALL` order.
pub bind_actions: [&'static str; 10],
pub pad_help1: &'static str,
pub pad_help2: &'static str,
pub match_pad_joined: &'static str,
pub match_pad_hint: &'static str,
/// Under the match card when nobody would play against player 1: no
/// AI, and no second player has joined by pad or by their keys.
pub match_needs_opponent: &'static str,
pub val_arrows: &'static str,
pub val_ijkl: &'static str,
pub val_on: &'static str,
pub val_off: &'static str,
/// Team modes in `TeamMode::ALL` order: free-for-all, pairs, trios.
pub team_modes: [&'static str; 3],
// Match setup rows
/// The heading over the match setup card.
pub match_heading: &'static str,
pub match_players: &'static str,
pub match_ai: &'static str,
pub human_one: &'static str,
pub human_many: &'static str,
pub match_ai_level: &'static str,
pub bot_levels: [&'static str; 3],
pub match_map: &'static str,
pub match_gulls: &'static str,
pub match_round: &'static str,
/// The arrows-per-player dial on the match setup card.
pub match_posts: &'static str,
/// The word that starts a round, after the count (see `countdown`).
pub countdown_go: &'static str,
pub match_mode: &'static str,
/// Seat-naming row: its label, what an unnamed seat shows, and the hint
/// shown while the row is being typed into.
pub match_name: &'static str,
pub match_name_empty: &'static str,
pub match_name_typing: &'static str,
pub mode_names: [&'static str; 3],
pub tour_round: &'static str,
pub tour_champion: &'static str,
/// A decided series with no one ahead: rounds lost to dead heats, or
/// a tally tied after the last round.
pub tour_drawn: &'static str,
pub tour_next: &'static str,
// Versus sidebar event log
pub log_raid: &'static str,
pub log_golden: &'static str,
pub log_lure: &'static str,
pub log_tier: &'static str,
pub log_gull: &'static str,
pub log_surge: &'static str,
pub log_golden_call: &'static str,
/// A sparkling crab banked while the event wheel was locked. `{p}`.
pub log_wheel_locked: &'static str,
/// A golden crab came out of its hole.
pub log_golden_out: &'static str,
pub map_names: [&'static str; 6],
/// How a handmade beach reads on the map dial.
pub map_custom: &'static str,
/// The same, for one too big to fit an invitation: it plays at this
/// table and cannot travel to another.
pub map_custom_local: &'static str,
/// Said beside the map dial when the player has beaches saved and none
/// of them has a castle for every seat at this table.
pub map_none_seats: &'static str,
pub gull_names: [&'static str; 3],
pub round_names: [&'static str; 3],
// Lobby
pub lobby_hosting: &'static str,
pub lobby_hosting_noport: &'static str,
pub lobby_rivals_one: &'static str,
pub lobby_rivals_many: &'static str,
pub lobby_aboard: &'static str,
/// Appended to the host's status when AI seats will fill the rest.
pub lobby_ai_seats: &'static str,
/// Appended to the host's status when people are watching.
pub lobby_watchers: &'static str,
/// Shown to a peer that joined to watch rather than play.
pub lobby_watching: &'static str,
/// Shown once W has armed the next join to be a watch.
pub lobby_watch_armed: &'static str,
/// The header while watching someone else's match.
pub title_watching: &'static str,
pub lobby_listening: &'static str,
pub lobby_none_yet: &'static str,
/// Tacked onto a beach whose round has already begun, after its seat
/// count: pressing its number queues for the next round rather than
/// joining this one.
pub lobby_in_progress: &'static str,
/// A beach with no chair left, this round or the next.
pub lobby_full_tag: &'static str,
/// Shown under the chat feed when the keyboard is free.
pub lobby_chat_hint: &'static str,
/// Asked before a player may host or join, and before a beach is put
/// on the air. An empty answer is refused rather than accepted.
pub lobby_ask_player_name: &'static str,
pub lobby_ask_game_name: &'static str,
pub lobby_needs_name: &'static str,
/// What the name box holds for a player who has never given one, so a
/// pad, which cannot type, can still say who it is: "Crab {n}", `{n}`
/// a two-digit number that tells two of them apart.
pub lobby_suggest_name: &'static str,
/// The same for a beach nobody has named yet, `{p}` its host.
pub lobby_suggest_beach: &'static str,
/// The lines a pad can say without a keyboard: North opens the chat
/// line with the first, and each North after it moves to the next.
pub quick_chat: [&'static str; 6],
/// Asked by J: the address of a beach no beacon reached, because the
/// network drops broadcasts or the host is on the other side of one.
pub lobby_ask_address: &'static str,
/// What was typed there is not `ip:port`. The example is half the
/// message: "not an address" tells nobody what one looks like.
pub lobby_bad_address: &'static str,
/// The host's own address, shown while hosting so it can be read out
/// to somebody who has to dial it by hand.
pub lobby_hosting_at: &'static str,
/// Dialled, and nobody has answered yet. Not the same as being at a
/// beach, and saying so is the difference between "they have not
/// started yet" and "there is nothing at that address".
pub lobby_calling: &'static str,
/// And nobody ever did.
pub lobby_no_answer: &'static str,
/// Headings over the two lobby panels.
pub lobby_card_beaches: &'static str,
pub lobby_card_chat: &'static str,
/// Said in the feed by the lobby itself, not by a player.
pub lobby_joined: &'static str,
/// The same news for somebody who came to watch rather than to play.
/// Its own line because "{p} joined" over a spectator reads as one
/// more rival, and the table counts its rivals.
pub lobby_watching_joined: &'static str,
pub lobby_left: &'static str,
/// Heading over the table, once you are at one.
pub lobby_card_players: &'static str,
/// Heading over the host's dials, which every peer can read.
pub lobby_card_terms: &'static str,
/// A player stopped sending and an AI took their chair, mid-round.
pub online_seat_abandoned: &'static str,
/// The host stopped sending, which no round survives: it relays
/// every input and calls every round. Read on the menu the joiners
/// are walked back to.
pub online_host_gone: &'static str,
/// On the menu after a shipped build caught a panic mid-round and
/// stopped the round rather than the game (`app::failsafe`).
pub round_failed: &'static str,
/// The host gave up on this seat: nothing it sent got through for
/// as long as the host waits before handing a seat to an AI. Read on
/// the menu, like `online_host_gone`.
pub online_dropped: &'static str,
/// Waiting for a match that is already under way: next in line, or
/// with `{n}` people ahead.
pub lobby_queued_next: &'static str,
pub lobby_queued_behind: &'static str,
/// The same news for somebody who came to watch. No place in the
/// queue, because a watcher is not in one: the crowd has room
/// whoever is playing, so there is nobody ahead of them.
pub lobby_queued_watching: &'static str,
/// Every chair at that beach is taken, this round and the next.
pub lobby_beach_full: &'static str,
pub lobby_join_list: &'static str,
/// The same line when there is exactly one, which "1 beaches" is not.
pub lobby_join_list_one: &'static str,
pub lobby_broadcasting: &'static str,
pub lobby_aboard_prompt: &'static str,
/// The same line for a spectator, who is not aboard: the status line
/// above it already says "watching", and two lines disagreeing about
/// which of those you are is worse than either.
pub lobby_watching_prompt: &'static str,
/// And for a peer in line for the next round, which has not started
/// when the host launches: it started without them.
///
/// It says where they are standing rather than what they will get: a
/// chair is free next round only if one of the players does not come
/// back, which nobody knows yet (see `OnlineSession::next_plan`).
pub lobby_queued_prompt: &'static str,
/// The same line for one of those who came to watch, who *can* be
/// promised what comes next: the crowd always has room.
pub lobby_queued_watch_prompt: &'static str,
pub lobby_could_not_host: &'static str,
pub lobby_could_not_join: &'static str,
pub lobby_version_clash: &'static str,
// Editor
pub ed_prompt: &'static str,
/// The editor's brush palette, in [`Brush::ALL`] order.
pub ed_brushes: [&'static str; 9],
/// The editor's readout of what the cursor is standing on.
pub ed_under: &'static str,
pub ed_playtest_prompt: &'static str,
pub ed_solvable: &'static str,
pub ed_solvable_free: &'static str,
pub ed_not_solvable: &'static str,
pub ed_solver_gave_up: &'static str,
pub ed_validating: &'static str,
pub ed_already_validating: &'static str,
/// What a freshly opened editor calls its level, and the row that
/// lets it be renamed.
/// Said after the beach is resized, which starts a fresh one.
pub ed_resized: &'static str,
pub ed_default_name: &'static str,
pub ed_name_row: &'static str,
pub ed_naming: &'static str,
pub ed_saved_to: &'static str,
pub ed_save_failed: &'static str,
/// Said when the save landed on a level this session did not put
/// there: the editor opens on the same default name every time, so
/// two levels left unnamed would quietly become one.
pub ed_saved_over: &'static str,
/// The first of the two presses that start a fresh beach, said when
/// there is a level on the board to lose.
pub ed_resize_confirm: &'static str,
/// The same for F4, a level pasted from a code in place of this one.
pub ed_paste_confirm: &'static str,
pub code_kind_beach: &'static str,
pub code_kind_level: &'static str,
pub code_kind_round: &'static str,
pub code_wrong_kind: &'static str,
pub code_copied: &'static str,
pub code_copy_failed: &'static str,
pub code_none_pasted: &'static str,
pub code_level_checking: &'static str,
pub code_level_bad: &'static str,
pub code_round_saved: &'static str,
pub code_round_bad: &'static str,
pub ed_posts: &'static str,
pub ed_fresh_sand: &'static str,
pub ed_back: &'static str,
pub ed_wrap_on: &'static str,
pub ed_wrap_off: &'static str,
pub ed_gulls_every: &'static str,
pub ed_gulls_off: &'static str,
/// Heading over the editor's puzzle/beach toggle.
pub ed_kind_row: &'static str,
/// The editor's status line for a beach, where the granted inventory
/// means nothing: how many seats it has castles for.
pub ed_seats: &'static str,
/// Said on saving a level that will appear on neither list.
pub ed_puzzle_no_crabs: &'static str,
/// What is being built, as it reads in the editor's title bar.
pub ed_kind_puzzle: &'static str,
pub ed_kind_arena: &'static str,
/// Said when the toggle is turned, one line each way: the kinds go to
/// different lists, so the answer has to say where this one now lands.
pub ed_now_puzzle: &'static str,
pub ed_now_arena: &'static str,
/// What checking a beach says, in place of the solver's verdict.
pub ed_arena_ok: &'static str,
pub ed_arena_needs_seats: &'static str,
pub ed_arena_no_crabs: &'static str,
// --- bot seats (docs/bot-seats.md) ---
/// The AI row's value for a seat a bot holds: a program somebody
/// wrote, connected over the network (`docs/bot-seats.md`).
pub match_bot: &'static str,
/// The doorway card's heading on a couch: bots to fill this table.
pub door_title_table: &'static str,
/// The doorway card's heading when joining a beach as a bot.
pub door_title_join: &'static str,
/// Over the connection strings: what to do with them.
pub door_start_with: &'static str,
/// A chair whose bot has not registered yet.
pub door_waiting: &'static str,
/// A chair whose bot has: its name and build, and its round trip.
pub door_connected: &'static str,
/// The doorway card once its bot is in, while the beach is greeted.
pub door_joining: &'static str,
/// The doorway card's keys, showing this machine's strings.
pub door_prompt: &'static str,
/// The doorway card's keys, showing the LAN's.
pub door_prompt_lan: &'static str,
/// A string went on the clipboard.
pub door_copied: &'static str,
/// The doorway could not open: no port to listen on.
pub door_could_not_listen: &'static str,
/// What a bot's seat is called: its name and its owner's, the robot
/// beside it saying the rest. The game sets this, never the bot, and it
/// travels in a name's twelve characters, so it is kept short.
pub bot_owned: &'static str,
/// A bot that gave no owner.
pub bot_unowned: &'static str,
/// A bot's connection went and the grace ran out: the AI took its
/// chair.
pub bot_stand_in: &'static str,
/// And it came back.
pub bot_back: &'static str,
/// The host's dial for letting bots in, and its two positions.
pub lobby_bots_dial: &'static str,
pub lobby_bots_values: [&'static str; 2],
/// Tried to join as a bot a beach that is not taking any.
pub lobby_no_bots: &'static str,
/// After a beach's name on the list, when it takes bots.
pub lobby_bots_tag: &'static str,
/// The host is choosing whom to ask to leave.
pub lobby_kick_ask: &'static str,
/// The feed, when somebody was asked to leave.
pub lobby_kicked_feed: &'static str,
/// The status line of the one who was.
pub lobby_kicked_you: &'static str,
/// A joiner's host went off the air while it waited in the lobby.
pub lobby_host_closed: &'static str,
/// The replay shelf: any replay file can be watched by dropping it.
pub replay_drop_hint: &'static str,
/// A dropped file that is not a replay this build plays.
pub replay_drop_bad: &'static str,
}
}
mod de;
mod en;
mod es;
mod fr;
mod it;
mod ja;
mod levels;
#[cfg(test)]
pub mod metrics;
mod nl;
mod ru;
pub use de::DE;
pub use en::EN;
pub use es::ES;
pub use fr::FR;
pub use it::IT;
pub use ja::JA;
use levels::{LEVEL_HINTS, LEVEL_NAMES};
pub use nl::NL;
pub use ru::RU;
#[cfg(test)]
mod tests {
use super::*;
use crate::app::cycle::{Cycle, Turn};
/// Every parameterized template must carry the same `{markers}` in
/// every language: a translation that drops one silently loses data
/// (a lure banner without its {p}, a score line without its {b}).
///
/// Both lists come from declarations rather than by hand (the fields
/// from the struct, the languages from [`ALL_LANGS`]), so this keeps
/// covering the whole table as both grow.
#[test]
fn placeholders_agree_across_languages() {
fn markers(s: &str) -> std::collections::BTreeSet<String> {
let mut out = std::collections::BTreeSet::new();
let mut rest = s;
while let Some(open) = rest.find('{') {
let Some(close) = rest[open..].find('}') else {
break;
};
out.insert(rest[open + 1..open + close].to_string());
rest = &rest[open + close + 1..];
}
out
}
let english = EN.strings();
for lang in ALL_LANGS {
for ((field, en), (_, translated)) in english.iter().zip(lang.tr().strings()) {
assert_eq!(
markers(translated),
markers(en),
"{field} placeholders diverge in {lang:?}"
);
}
}
}
/// Every Japanese character the game can put on screen has to be in
/// the subset that ships, or that word draws as a row of nothing.
/// Reword a Japanese string and this is the test that says to run
/// `tools/gen_jp_font.py` again.
///
/// That face is a subset, a whole CJK font being twenty megabytes for
/// the few hundred characters this game says, and a character left out
/// draws as nothing with no warning. So this reads the `cmap` of the
/// very bytes that ship.
///
/// Only the characters DejaVu cannot draw are asked for, which is the
/// line the tool cuts on too: the Latin and the digits in a Japanese
/// prompt are drawn by the font the rest of the game uses.
#[test]
fn the_japanese_font_carries_every_character_the_tables_use() {
let covered = metrics::characters_in_font(include_bytes!(
"../../../assets/fonts/NotoSansMonoCJKjp-Subset.otf"
));
assert!(
covered.len() > 300,
"only {} characters shipped",
covered.len()
);
let column = Lang::Ja.column();
let mut said: String = JA.strings().iter().map(|(_, line)| *line).collect();
for row in &LEVEL_NAMES {
said.push_str(row[column]);
}
for row in &LEVEL_HINTS {
said.push_str(row[1 + column]);
}
// And the language's own name, which the picker draws in every
// language, before a Japanese string has ever been asked for.
said.push_str(Lang::Ja.native_name());
for ch in said.chars().filter(|ch| *ch > '\u{4ff}') {
assert!(covered.contains(&ch), "{ch:?} is not in the shipped subset");
}
}
/// The display face draws the header, clocks, scores, banners and
/// headings, any of which may be any string in any table. Nunito is a
/// whole font rather than a subset, but a character it lacks would draw
/// as nothing all the same, so every character every language says is
/// held to it, bar the Japanese that falls back to the subset.
#[test]
fn the_display_font_carries_every_character_but_japanese() {
let display = metrics::display_covers();
let kanji = metrics::characters_in_font(include_bytes!(
"../../../assets/fonts/NotoSansMonoCJKjp-Subset.otf"
));
for lang in ALL_LANGS {
let column = lang.column();
let mut said: String = lang.tr().strings().iter().map(|(_, line)| *line).collect();
for row in &LEVEL_NAMES {
said.push_str(row[column]);
}
for row in &LEVEL_HINTS {
said.push_str(row[1 + column]);
}
said.push_str(lang.native_name());
for ch in said.chars().filter(|ch| !ch.is_control()) {
assert!(
display.contains(&ch) || kanji.contains(&ch),
"{lang:?} says {ch:?}, which neither the display face nor the subset draws"
);
}
}
}
/// The old hand-written list checked 53 fields; the generated walk must
/// reach far more than that, or the macro is not expanding what we think.
#[test]
fn the_walk_reaches_the_whole_table() {
let strings = EN.strings();
assert!(strings.len() > 300, "only {} strings walked", strings.len());
assert!(strings.iter().any(|(field, _)| field == "tagline"));
assert!(strings.iter().any(|(field, _)| field == "ach_names[31]"));
}
#[test]
fn language_keys_round_trip() {
for lang in ALL_LANGS {
assert_eq!(Lang::from_key(lang.key()), lang);
}
assert_eq!(Lang::from_key("??"), Lang::En);
}
#[test]
fn cycling_visits_every_language() {
let mut lang = Lang::En;
for _ in 0..ALL_LANGS.len() {
lang = lang.cycled(Turn::Right);
}
assert_eq!(lang, Lang::En);
assert_eq!(Lang::En.cycled(Turn::Left), *ALL_LANGS.last().unwrap());
}
#[test]
fn builtin_level_names_translate_and_custom_pass_through() {
assert_eq!(Lang::Fr.level_name("Gull Storm"), "Tempête de mouettes");
assert_eq!(Lang::De.level_name("Gull Storm"), "Möwensturm");
assert_eq!(Lang::Es.level_name("Gull Storm"), "Tormenta de gaviotas");
assert_eq!(Lang::It.level_name("Gull Storm"), "Tempesta di gabbiani");
assert_eq!(Lang::Nl.level_name("Gull Storm"), "Meeuwenstorm");
assert_eq!(Lang::Ru.level_name("Gull Storm"), "Чаячий шторм");
assert_eq!(Lang::Ja.level_name("Gull Storm"), "カモメの嵐");
assert_eq!(Lang::En.level_name("Gull Storm"), "Gull Storm");
assert_eq!(Lang::Fr.level_name("My Custom Beach"), "My Custom Beach");
}
/// Every campaign and challenge level ships a name in every language.
#[test]
fn every_builtin_level_is_covered() {
for level in crate::sim::campaign_levels()
.iter()
.chain(crate::sim::challenge_levels().iter())
{
assert!(
LEVEL_NAMES.iter().any(|row| row[0] == level.name),
"missing translation row for level {:?}",
level.name
);
}
}
/// No column of either level table may be left blank, which is what a
/// row padded out to reach the new width would look like: the lookup
/// would find the row, hand back an empty string, and draw a level
/// with no name at all.
#[test]
fn every_level_column_is_filled() {
for lang in ALL_LANGS {
for row in &LEVEL_NAMES {
assert!(
!row[lang.column()].trim().is_empty(),
"{:?} has no {lang:?} name",
row[0]
);
}
for row in &LEVEL_HINTS {
assert!(
!row[1 + lang.column()].trim().is_empty(),
"{:?} has no {lang:?} hint",
row[0]
);
}
}
}
}