All files / app-play/src player-copy.ts

39.73% Statements 60/151
41.66% Branches 10/24
35.46% Functions 50/141
38.92% Lines 58/149

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                  3x     38x                                 3x                                                                                                                                                                                                                                                 2x         1x                                                         1x         7x 6x 3x         3x 3x 1x           1x 3x     8x 1x 1x 1x 1x   1x   1x   1x                         1x     2x         19x               2x 1x       3x     7x   1x   3x 1x 1x                                                                   4x 6x                                           3x                       2x   1x   1x   3x         3x                                                                   3x                                                                                     2x                                                                                           38x                                                                                                                                                                                                                                                                                                                                                                                                   1x                                                                                           1x       1x                                                                                                                                                                                                                                                                                                                                                                                                                   38x       38x   38x       4x 4x 4x         9x       417x                   19x 19x 19x    
/**
 * User-facing copy for the web player. English is the reference. Japanese has the same shape.
 * The language follows the browser, and the Help language switch, the same way the Help panes do.
 * Product names (Leaderboard, LR2, beatoraja, Google, Discord) and ruleset tokens stay as they are.
 */
 
export type PlayerLang = 'en' | 'ja';
 
export function resolvePlayerLang(language: string | undefined): PlayerLang {
  return language?.toLowerCase().startsWith('ja') ? 'ja' : 'en';
}
 
const en = {
  shell: {
    search: 'Search title / artist / genre... (? for a filter)',
    dropTitle: 'Drop to load',
    closeDropCard: 'Close drop card',
    openFolder: 'Open folder',
    savedFolders: 'Folders to load',
    savedFoldersHint:
      'Changes apply the next time you open the player. Removing a folder only removes its registration.',
    sessionFolders: 'Folders loaded for this visit',
    changeFolder: 'Change',
    removeFolder: 'Remove',
    addFolder: 'Add folder',
    changeSavedFolder: (name: string) => `Change ${name}`,
    removeSavedFolder: (name: string) => `Remove ${name}`,
    reconnectFolder: (name: string) => `Reconnect ${name}`,
    forgotUnansweredFolders: (names: readonly string[]) =>
      `Removed from the folders to load because the browser could not open them: ${names.join(', ')}. Add a folder again to load it.`,
    rememberedFolderError: 'Could not open or remember the folder.',
    bemuseServers: 'Bemuse music servers',
    bemuseServersHint:
      'The public Bemuse servers are registered to start with. Registered servers are listed each time you open the player, and sound files download when you play a song. Removing a server applies the next time you open the player.',
    bemuseServerURL: 'Server URL',
    addBemuseServer: 'Add server',
    restoreBemuseServers: 'Add default servers',
    removeBemuseServer: (name: string) => `Remove ${name}`,
    invalidBemuseServerURL: 'Enter the http(s) URL of a Bemuse music server.',
    courseTables: 'Difficulty tables',
    courseTablesHint:
      'Courses of these difficulty tables are listed on the select screen. Well-known tables are registered to start with, and every table is imported again each time you open the player. Enter a table page or its header JSON URL to add one.',
    courseTableURL: 'Table URL',
    addCourseTable: 'Add table',
    restoreCourseTables: 'Add default tables',
    removeCourseTable: (name: string) => `Remove ${name}`,
    invalidCourseTableURL: 'Enter the http(s) URL of a difficulty table.',
    openZIP: 'Open ZIP',
    dropFolder: 'BMS folder',
    dropLR2Skin: 'LR2 skin',
    dropBeatorajaSkin: 'beatoraja skin',
    submitPlays: 'Submit my plays to the Leaderboard',
    checkingAccount: 'Checking account…',
    leaderboard: 'Leaderboard',
    sound: 'Sound',
    systemCheck: 'System check',
    required: 'Required',
    optional: 'Optional',
    browserReady: 'Browser ready',
    optionalMissing: (count: number) => `Browser ready · ${count} optional missing`,
    browserUnsupported: 'Browser not supported',
    missingRequired: (names: string) => `Missing required: ${names}`,
    supported: 'supported',
    missingRequiredItem: 'missing (required)',
    missingOptionalItem: 'missing (optional)',
    signIn: 'Sign in',
 
    signInGoogleSoon: 'Sign in with Google is coming soon',
    signInDiscordSoon: 'Sign in with Discord is coming soon',
    comingSoon: 'Coming soon',
 
    cancel: 'Cancel',
 
    signUpGoogleSoon: 'Sign up with Google is coming soon',
    signUpDiscordSoon: 'Sign up with Discord is coming soon',
 
    handle: 'Handle',
 
    displayName: 'Name',
 
    skinDropLr2: 'Drop an LR2 skin',
    skinDropBeatoraja: 'Drop a beatoraja skin',
    skinDropHintLr2:
      'Drop the folder that holds your LR2 theme (<code>LR2files/Theme/…</code>, with its <code>.lr2skin</code> files).',
    skinDropHintBeatoraja:
      'Drop the folder that holds your beatoraja skin (its <code>.luaskin</code> or <code>.json</code> skin files).',
    skinSwitchTitle: 'Use the dropped skin?',
    skinSwitchDoNotAsk: 'Do not ask again',
    skinSwitchHint: 'Switch to this skin? Cancel keeps your current skin. Charts in the drop will still be imported.',
    useLr2: 'Use LR2 skin',
    useBeatoraja: 'Use beatoraja skin',
    chartsMissing: 'Charts missing',
    ok: 'OK',
    exitMenuTitle: 'Exit Be-Music Play?',
    exitMenuHint: 'Close this window and exit. Cancel stays on the select screen.',
    exitMenuLeave: 'Close window',
    exitMenuCancel: 'Cancel',
    windowCloseBlocked: 'Your browser kept this window open. Close this tab or window to exit.',
    optionUnavailable: 'Option not available',
    optionUnavailableHint:
      'The selected play options cannot be used with this chart. Change them and start the chart again.',
    loading: 'Loading…',
    helpAbout: 'Help & About',
    fullscreenExit: 'Exit full screen',
    installTitle: 'Install Be-Music Play',
    installLead: 'Safari installs web apps from its own menu.',
    installIOSShare: 'Tap the Share button.',
    installIOSAdd: 'Choose “Add to Home Screen”.',
    installMacFile: 'Open the File menu.',
    installMacAdd: 'Choose “Add to Dock”.',
    close: 'Close',
    usage: 'Usage',
    keyboard: 'Keyboard',
    options: 'Options',
    optionsSearch: 'Search options',
    optionsSearchEmpty: 'No option matches.',
    acknowledgements: 'Acknowledgements',
    language: 'Language',
    pause: 'Pause',
    quit: 'Quit',
    rotateTitle: 'Rotate your device',
    rotateSubtitle: 'The player is laid out for landscape.',
    services: 'Services',
    ackLoading: 'Loading…',
    ackFailed: 'Could not load the list.',
    ackEmpty: 'No third-party packages were found in this build.',
    ackLicense: 'Copyright and license text',
    ackNoLicense: 'No LICENSE file shipped with this package.',
    yourPage: 'Your Leaderboard page (opens in a new tab)',
  },
  phases: {
    enumerating: 'Collecting files…',
    reading: 'Reading files…',
    parsing: 'Parsing charts…',
    theme: 'Loading LR2 theme…',
  },
  compatNotes: {
    webgl2: 'Pixi rendering pipeline (or WebGPU)',
    'web-audio': 'Keysound and BGM playback',
    'file-api': 'Loads BMS folders / LR2 themes from drag-drop',
    webassembly: 'BGA video transcode (ffmpeg.wasm)',
    worker: 'Off-main-thread BGA transcoding',
    webgpu: 'Preferred GPU path; auto-falls-back to WebGL2',
    webcodecs: 'Hardware-accelerated BGA encode',
    'media-recorder': 'Gameplay → WebM recording',
    'offscreen-canvas': 'LR2 bitmap-font conversion',
  },
  account: {
    notSignedIn: 'Not signed in',
    anonymous: 'guest',
    passkey: (count: number) => `${count} passkey${count === 1 ? '' : 's'}`,
    chipSignedOutTitle: 'Not signed in to the Leaderboard. Open Options → Leaderboard to sign in.',
    chipAnonymousTitle:
      'Signed in as a guest: keep this account with a passkey, Google or Discord to show its plays on the Leaderboard.',
    chipSignedInTitle: (name: string, handle: string) =>
      `Signed in as ${name} (@${handle}). Opens your Leaderboard page.`,
    startSignedOutHint: 'Sign in through Accounts before submitting plays. You can start with a guest account.',
    startAnonymousHint:
      'Rankings leave guest accounts out, and other devices cannot sign in to one. Keep it with a passkey, Google or Discord to join them.',
    signUp: 'Sign up',
    signIn: 'Sign in',
    signInLead: 'Sign in with a passkey, Google or Discord to submit your plays.',
    signInPasskey: 'Sign in with a passkey',
    signInGoogle: 'Sign in with Google',
    signInDiscord: 'Sign in with Discord',
    or: 'or',
    noAccount: 'No account yet?',
    signedInLead: 'Your plays are submitted to this account.',
    myPage: 'My page',
    anonymousLead: 'Signed in as a guest. Keep this account to show its plays in the rankings, or sign in to another.',
    keep: 'Keep this account',
    signOut: 'Sign out',
    manage: 'Manage account',
    signInFailed: 'Sign-in failed',
    signUpFailed: 'Sign-up failed',
    couldNotSignOut: 'Could not sign out.',
    accountReadyPrefix: 'Your account is ready',
    handleReserved: 'That handle is reserved. Pick another.',
    handleFormat: 'Handles are 3 to 15 letters, digits or _.',
    nameEmpty: 'The name cannot be empty.',
    nameLength: 'Names are at most 32 characters.',
    nameCharacters: 'Names cannot contain line breaks or control characters.',
    handleTaken: 'That handle is taken.',
    signInFirst: 'Sign in first.',
    somethingWrong: (error: string) => `Something went wrong (${error}).`,
  },
  record: {
    full: 'Record: score, lamp and play count are saved · Leaderboard: main board',
    assisted: (assistClass: string, lamp: string, options: string) =>
      `${assistClass} (${options}): ${lamp} and play count only, no score · Leaderboard: assisted board`,
    notSaved: (options: string) => `Not saved (${options}): no record · Leaderboard: stored, not ranked`,
    conditional: (options: string, consequence: string) => `— on a chart ${options} changes: ${consequence}`,
    autoPlay: 'AUTO PLAY: no record, and nothing is sent to the Leaderboard',
    twoPlayer: 'Two-player BATTLE: the replay is kept, the record and the ranking are not',
    bmsonTotal: 'bmson TOTAL 0 without recovery: no record · Leaderboard: stored, not ranked',
    lampKept: 'lamp',
    lampCap: (lamp: string) => `lamp up to ${lamp}`,
    lampReplace: (lamp: string) => `${lamp} lamp`,
    separateLamp: (slot: string) => ` (kept apart as ${slot})`,
    classes: { light: 'LIGHT ASSIST', assist: 'ASSIST' },
    slots: { 'd-battle': 'D-BATTLE', 'sp-to-dp': 'SP TO DP', extra: 'EXTRA MODE' },
    board: { main: 'main board', assisted: 'assisted board' },
  },
  replay: {
    invalid: (message: string) => `Replay: invalid replay (${message})`,
    notLoaded: (title: string) => `Replay: chart not loaded (${title})`,
    untitled: 'untitled',
    loadChart: 'Load this chart to watch the replay, then drop the replay again.',
    replaying: (title: string) => `Replaying: ${title}`,
    failed: (message: string) => `Replay failed: ${message}`,
    slotUnreadable: (slot: number) => `Replay slot ${slot} could not be read`,
    replayingSlot: (slot: number, title: string) => `Replaying slot ${slot}: ${title}`,
    slotDeleted: (slot: number) => `Cleared replay slot ${slot}`,
    slotNotDeleted: (slot: number) => `Replay slot ${slot} could not be deleted`,
    invalidCourse: (message: string) => `Course replay: invalid course replay (${message})`,
    stagesMissing: (missing: number, total: number) =>
      `Course replay: ${missing} of ${total} stage charts are not loaded`,
    loadStages: (name: string) =>
      `Load these charts of ${name} to replay the course, then drop its course replay again.`,
    courseFailed: (message: string) => `Course replay failed: ${message}`,
    untitledChart: 'untitled chart',
    slotsTitle: 'Replay slots',
    slotsAndHistory: 'Replay slots and history',
    historyTitle: 'Replay history',
    allHistory: 'Show all charts and courses',
    emptyHistory: 'No replays in history.',
    loadingHistory: 'Loading replay history…',
    historyUnreadable: 'Could not read this replay.',
    historyDeleted: 'Deleted the replay from history.',
    historyNotDeleted: 'Could not delete the replay.',
    confirmDeleteHistory: (title: string) =>
      `Delete the replay of “${title}” from history and clear any slots that select it?`,
    clearSlot: 'Clear slot',
    confirmClearSlot: (slot: number, title: string) =>
      `Clear slot ${slot} for “${title}”? The replay stays in history.`,
    save: 'Save',
    saved: 'Saved',
    savedNow: 'Saved now',
    empty: 'Empty',
    slot: (slot: number) => `Slot ${slot}`,
    saveHint: 'Select this play for a slot (keys 1–4). Each slot points to one replay in history.',
    cannotSave: 'This play cannot be saved to a slot.',
    replay: 'Replay',
    download: 'Download',
    delete: 'Delete',
  },
  lb: {
    notSubmitted: (error: string) => `Leaderboard: not submitted (${error})`,
    courseNotSubmitted: (error: string) => `Leaderboard: course not submitted (${error})`,
    network: 'Leaderboard: not submitted (network error)',
    courseNetwork: 'Leaderboard: course not submitted (network error)',
    notImproved: 'Leaderboard: not submitted (EX-SCORE did not improve)',
    stored: (reason: string, again: string) => `Leaderboard: stored, not ranked (${reason})${again}`,
    submitted: 'Leaderboard: submitted',
    ranked: (ruleset: string, rank: number, players: number, exScore: number, best: string, again: string) =>
      `Leaderboard ${ruleset}: #${rank} / ${players} · EX ${exScore}${best}${again}`,
    courseRanked: (ruleset: string, rank: number, players: number, exScore: number, best: string, again: string) =>
      `Leaderboard course ${ruleset}: #${rank} / ${players} · EX ${exScore}${best}${again}`,
    already: ' (already submitted)',
    newBest: (parts: string) => ` · new best ${parts}`,
    notSimulated: (rulesets: string) => ` · not simulated under ${rulesets}`,
    truncated: (rulesets: string) => ` · judged only up to the failure under ${rulesets}`,
    lamp: 'lamp',
    unranked: {
      'bmson-total': 'bmson TOTAL 0 used no recovery',
      tempo: 'a play at another tempo is practice',
      'course-stage': 'a course stage ranks with its course',
      'no-save': 'an option that saves no record was on',
      unreleased: 'a made course is ranked only once flagged for IR, and a random course never is',
    },
    skipped: {
      'two-player': 'Leaderboard: not submitted (two-player plays have no single-player ranking)',
      'auto-play': 'Leaderboard: not submitted (an auto play is not sent)',
      'missing-fingerprint': 'Leaderboard: not submitted (this replay has no chart fingerprint)',
      'fingerprint-mismatch': 'Leaderboard: not submitted (the chart does not match the recorded play)',
    },
    courseSkipped: {
      'two-player': 'Leaderboard: course not submitted (two-player plays have no single-player ranking)',
      'auto-play': 'Leaderboard: course not submitted (an auto play is not sent)',
      aborted: 'Leaderboard: course not submitted (a stage before the last was given up)',
      'not-a-course-run': 'Leaderboard: course not submitted (the stages do not make one run)',
      'missing-fingerprint': 'Leaderboard: course not submitted (a stage chart has no fingerprint)',
      'fingerprint-mismatch': 'Leaderboard: course not submitted (a stage chart does not match the recorded play)',
    },
  },
  course: {
    making: 'Making a course: decide charts to add them, then save',
    newCourse: (kind: string) => `New ${kind} course`,
    decideCharts: 'Decide charts to add them (up to 5, in the first chart’s key mode).',
    chartCount: (count: number) => `${count} / 5 charts`,
    courseName: 'Course name',
    connection: 'Connection',
    removeLast: 'Remove last',
    save: 'Save',
    stopped: 'Stopped making the course',
    saved: (name: string) => `Saved the course "${name}"`,
    added: (title: string, count: number) => `Added ${title} to the course (${count} / 5)`,
    couldNotAdd: (title: string, reason: string) => `Could not add ${title}: ${reason}`,
    addReasons: {
      full: 'the course already has 5 charts',
      'key-mode': 'its key mode differs from the first chart’s',
      'no-md5': 'its chart could not be hashed',
      'not-making': 'no course is being made',
    },
    unsaved: 'Could not save your courses in this browser; they last until the page is closed',
    empty: 'No course yet. Decide NEW COURSE in a course folder to make one.',
    exportLr2: 'Export .lr2crs',
    exportBeatoraja: 'Export beatoraja .json',
    myCourses: 'My courses',
    myCoursesLead: 'Courses you made, kept in this browser.',
    delete: 'Delete',
    confirmDelete: (name: string) => `Delete the course "${name}"?`,
    registerIR: 'Register for IR',
    confirmIR: (name: string) =>
      `Register the course "${name}" for IR? Its runs are then ranked, and its connections and constraints can no longer be changed. This cannot be undone.`,
    irOn: 'IR ON: ranked; connections and constraints are fixed',
    close: 'Close',
    stageMissing: (name: string, count: number) =>
      count === 1 ? `${name}: 1 stage is not in the collection` : `${name}: ${count} stages are not in the collection`,
    missingStages: {
      title: 'Stages missing',
      hint: (name: string) =>
        `${name} needs these charts. Open their pages to download them, then load them to play the course.`,
      stage: (stage: number) => `Stage ${stage}`,
      looking: 'Looking up download pages…',
      noLink: 'No download page listed',
      song: 'Song',
      diff: 'Chart',
      pack: 'Pack',
    },
    randomNoChart: (name: string, stage: number) => `${name}: stage ${stage} matches no chart`,
    randomBadFilter: (name: string, stage: number, error: string) =>
      `${name}: stage ${stage} has an invalid filter (${error})`,
    nonstopLayout: (name: string, stage: string) =>
      `${name}: all NONSTOP stages must use the same generic keyboard layout${stage}`,
    nonstopStitch: (name: string, reason: string, stage: string) =>
      `${name}: cannot stitch the NONSTOP course: ${reason}${stage}`,
    nonstopLRXMixed: (name: string, stage: string) =>
      `${name}: a NONSTOP course cannot mix LRX charts with BMS or bmson charts${stage}`,
    nonstopLRXLayout: (name: string, stage: string) =>
      `${name}: all LRX stages of a NONSTOP course must use the same lane type${stage}`,
    stageNote: (stage: number) => ` (stage ${stage})`,
    constraints: {
      option: 'Lane option',
      speed: 'Hi-speed',
      judge: 'Judgment',
      gauge: 'Gauge',
      longNote: 'Long notes',
    },
    choices: {
      free: 'Free',
      normal: 'Normal',
      offOnly: 'Off only (CLASS)',
      offOrMirror: 'Off or MIRROR',
      randomFamily: 'Random family',
      locked: 'Locked',
      noGreat: 'No GREAT',
      noGood: 'No GOOD',
      playersChoice: 'Player’s choice',
      keys5: '5 keys',
      keys7: '7 keys',
      keys9: '9 keys',
      keys24: '24 keys',
      asCharted: 'As charted',
    },
    randomMix: {
      preferredLevel: 'Favorite level',
      bpmRange: 'BPM range',
      maxBPM: 'Max BPM',
      minBPM: 'Min BPM',
    },
    randomMixDialog: {
      title: 'RANDOM MIX',
      hint: 'Choose which charts to draw from, then press OK to start.',
      keys: 'Keys',
      keyMode: (keyMode: number) => `${keyMode} KEYS`,
      narrowBy: 'Narrow by',
      byLevel: 'Level',
      byDifficulty: 'Difficulty',
      minLevel: 'Min level',
      maxLevel: 'Max level',
      anyLevel: 'Any',
      difficulty: 'Difficulty',
      estimateDifficulty: 'Estimate a missing #DIFFICULTY',
      allowBPMChanges: 'Draw charts whose BPM changes',
      count: 'Stages',
      settings: 'Draw settings',
      defaultConnection: 'Connection',
      infinity: 'Infinity',
      nonstopNoInfinity: 'A NONSTOP mix is stitched before it starts, so it cannot be endless.',
      matches: (count: number) => (count === 1 ? '1 chart matches.' : `${count} charts match.`),
      noMatch: 'No chart matches these conditions.',
      noFirstStage: (count: number) =>
        `${count === 1 ? '1 chart matches' : `${count} charts match`}, but none can be stage 1 under the draw settings: unless charts whose BPM changes are drawn, stage 1 must keep one BPM under a BPM range, and the BPM limits apply. Draw charts whose BPM changes, set the BPM range to NO LIMIT or widen the BPM limits.`,
      cancel: 'Cancel',
      ok: 'OK',
    },
    randomMixSave: {
      title: 'Save this RANDOM MIX?',
      hint: 'Save the stages drawn as a course of your own. The settings below drew them and cannot be changed here.',
      name: 'Course name',
      stages: (count: number) => (count === 1 ? '1 stage' : `${count} stages`),
      settings: 'Started with',
      settingsFixed: 'These are the settings the RANDOM MIX was started with.',
      kind: 'Course',
      on: 'On',
      off: 'Off',
      none: 'None',
      discard: 'Don’t save',
      save: 'Save',
    },
    randomMixNoMatch: 'RANDOM MIX: no chart matches the conditions',
  },
  practice: {
    title: 'PRACTICE',
    lead: 'Press a bar to hear it. Shift-press or drag to pick a run of bars, then Start practice to loop them.',
    wholeChart: 'No bars picked: the whole chart loops',
    bars: (first: string, last: string, from: string, to: string) =>
      first === last ? `Bar ${first} · ${from} → ${to}` : `Bars ${first}–${last} · ${from} → ${to}`,
    start: 'Start practice',
    playNormally: 'Play without practice',
    clear: 'Whole chart',
    cancel: 'Cancel',
    loading: 'Reading the chart…',
    unreadable: 'This chart has no bars to show; Start practice loops the whole chart.',
  },
  camera: {
    defaultCamera: 'Default camera',
    unnamed: (index: number) => `Camera ${index}`,
    missingChoice: (label: string) => `${label} (not connected)`,
    previewLabel: 'Camera preview',
    previewOff: 'Turn on “Show camera in BGA” to see the camera here. The preview stops when you leave this tab.',
    status: {
      off: 'Off. The BGA frame shows the chart’s BGA.',
      standby: 'On. The camera opens when a play starts.',
      starting: 'Opening the camera…',
      live: 'Showing the camera in the BGA frame.',
      denied: 'Camera access is blocked. Allow it in the browser’s site settings, then press “Allow camera access”.',
      missing: 'The camera is not connected. The play shows the BGA until it is.',
      busy: 'The camera could not start (another app may be using it).',
      unsupported: 'This browser cannot open a camera on this page.',
    },
    needNames: 'Press “Allow camera access” once to see the cameras by name.',
    privacy: 'The picture stays on this device. A Capture recording includes it, in the BGA frame.',
    lost: {
      denied: 'Camera access was refused. Showing the BGA.',
      missing: 'The camera is not connected. Showing the BGA.',
      busy: 'The camera could not start. Showing the BGA.',
      unsupported: 'This browser cannot open a camera here. Showing the BGA.',
    },
  },
  embed: {
    needTrack: 'Add ?track= with the URL of a chart archive (.zip) to preview it.',
    loadFailed: (message: string) => `Could not load the track: ${message}`,
    noChart: 'The track holds no playable chart.',
    noStage: 'The course holds no playable stage.',
    loadingTrack: 'Loading track',
    downloading: (size: string) => `Downloading track… ${size}`,
    reading: (current: number, total: number) =>
      total > 0 ? `Reading charts… ${current} / ${total}` : 'Reading charts…',
    badCourseFile: 'Choose an LR2 .lr2crs or beatoraja .json course file.',
  },
};
 
const ja: typeof en = {
  shell: {
    search: 'タイトル / アーティスト / ジャンルを検索(? でフィルタ)',
    dropTitle: 'ドロップして読み込む',
    closeDropCard: 'ドロップカードを閉じる',
    openFolder: 'フォルダを開く',
    savedFolders: '読み込み対象フォルダ',
    savedFoldersHint: '変更はプレイヤーの次回起動時に反映されます。削除しても元のフォルダは残ります。',
    sessionFolders: '今回読み込んだフォルダ',
    changeFolder: '変更',
    removeFolder: '削除',
    addFolder: 'フォルダを追加',
    changeSavedFolder: (name: string) => `${name} を変更`,
    removeSavedFolder: (name: string) => `${name} の登録を削除`,
    reconnectFolder: (name: string) => `${name} に再接続`,
    forgotUnansweredFolders: (names: readonly string[]) =>
      `ブラウザが開けなかったため、${names.join('、')} を読み込み対象フォルダから外しました。読み込むにはフォルダを追加し直してください。`,
    rememberedFolderError: 'フォルダを開くか、保存することができませんでした。',
    bemuseServers: 'Bemuse 音楽サーバー',
    bemuseServersHint:
      '公開されている Bemuse サーバーが最初から登録されています。登録したサーバーの曲はプレイヤーを開くたびに一覧に出て、音声は曲を遊ぶときにダウンロードします。削除はプレイヤーの次回起動時に反映されます。',
    bemuseServerURL: 'サーバー URL',
    addBemuseServer: 'サーバーを追加',
    restoreBemuseServers: '既定のサーバーを追加',
    removeBemuseServer: (name: string) => `${name} の登録を削除`,
    invalidBemuseServerURL: 'Bemuse 音楽サーバーの http(s) URL を入力してください。',
    courseTables: '難易度表',
    courseTablesHint:
      '登録した難易度表のコースが選曲画面に並びます。有名な表が最初から登録されていて、どの表もプレイヤーを開くたびに取り込み直します。追加するには、表のページかヘッダー JSON の URL を入力します。',
    courseTableURL: '表の URL',
    addCourseTable: '表を追加',
    restoreCourseTables: '既定の表を追加',
    removeCourseTable: (name: string) => `${name} の登録を削除`,
    invalidCourseTableURL: '難易度表の http(s) URL を入力してください。',
    openZIP: 'ZIP を開く',
    dropFolder: 'BMS フォルダ',
    dropLR2Skin: 'LR2 スキン',
    dropBeatorajaSkin: 'beatoraja スキン',
    submitPlays: 'プレイを Leaderboard に送信する',
    checkingAccount: 'アカウントを確認しています…',
    leaderboard: 'Leaderboard',
    sound: '音声',
    systemCheck: 'システムチェック',
    required: '必須',
    optional: '任意',
    browserReady: 'ブラウザは対応しています',
    optionalMissing: (count) => `ブラウザは対応しています · 任意の機能が ${count} 個不足`,
    browserUnsupported: 'このブラウザには対応していません',
    missingRequired: (names) => `必須の機能がありません: ${names}`,
    supported: '対応',
    missingRequiredItem: '不足(必須)',
    missingOptionalItem: '不足(任意)',
    signIn: 'ログイン',
 
    signInGoogleSoon: 'Google でのログインは準備中です',
    signInDiscordSoon: 'Discord でのログインは準備中です',
    comingSoon: '準備中',
 
    cancel: 'キャンセル',
 
    signUpGoogleSoon: 'Google での登録は準備中です',
    signUpDiscordSoon: 'Discord での登録は準備中です',
 
    handle: 'ユーザー名',
 
    displayName: '表示名',
 
    skinDropLr2: 'LR2 スキンをドロップ',
    skinDropBeatoraja: 'beatoraja スキンをドロップ',
    skinDropHintLr2:
      'LR2 テーマのフォルダ(<code>.lr2skin</code> がある <code>LR2files/Theme/…</code>)をドロップしてください。',
    skinDropHintBeatoraja:
      'beatoraja スキンのフォルダ(<code>.luaskin</code> または <code>.json</code>)をドロップしてください。',
    skinSwitchTitle: 'ドロップしたスキンを使いますか?',
    skinSwitchDoNotAsk: '今後表示しない',
    skinSwitchHint:
      'このスキンに切り替えますか?キャンセルすると今のスキンのままです。ドロップ内の譜面は読み込まれます。',
    useLr2: 'LR2 スキンを使う',
    useBeatoraja: 'beatoraja スキンを使う',
    chartsMissing: '譜面がありません',
    ok: 'OK',
    exitMenuTitle: 'Be-Music Play を終了しますか?',
    exitMenuHint: 'ウィンドウを閉じて終了します。キャンセルすると選曲画面に戻ります。',
    exitMenuLeave: 'ウィンドウを閉じる',
    exitMenuCancel: 'キャンセル',
    windowCloseBlocked:
      'ブラウザの制限でウィンドウを閉じられませんでした。このタブまたはウィンドウを閉じて終了してください。',
    optionUnavailable: '使えないオプション',
    optionUnavailableHint:
      '選んだプレイオプションはこの譜面では使えません。変更してから、もう一度譜面を始めてください。',
    loading: '読み込み中…',
    fullscreenExit: 'フルスクリーンを解除',
    helpAbout: 'ヘルプとこのプレイヤーについて',
    installTitle: 'Be-Music Play をインストール',
    installLead: 'Safari では、Web アプリを Safari のメニューから追加します。',
    installIOSShare: '共有ボタンをタップします。',
    installIOSAdd: '「ホーム画面に追加」を選びます。',
    installMacFile: 'メニューバーの「ファイル」を開きます。',
    installMacAdd: '「Dock に追加」を選びます。',
    close: '閉じる',
    usage: '使い方',
    keyboard: 'キーボード',
    options: 'オプション',
    optionsSearch: 'オプションを検索',
    optionsSearchEmpty: '一致するオプションがありません。',
    acknowledgements: '謝辞',
    language: '言語',
    pause: '一時停止',
    quit: 'やめる',
    rotateTitle: '端末を横向きにしてください',
    rotateSubtitle: 'プレイヤーは横向きの画面向けです。',
    services: 'サービス',
    ackLoading: '読み込み中…',
    ackFailed: '一覧を読み込めませんでした。',
    ackEmpty: 'このビルドに第三者パッケージはありません。',
    ackLicense: '著作権とライセンスの本文',
    ackNoLicense: 'このパッケージに LICENSE ファイルはありません。',
    yourPage: 'あなたの Leaderboard ページ(新しいタブで開きます)',
  },
  phases: {
    enumerating: 'ファイルを集めています…',
    reading: 'ファイルを読んでいます…',
    parsing: '譜面を解析しています…',
    theme: 'LR2 テーマを読み込んでいます…',
  },
  compatNotes: {
    webgl2: 'Pixi の描画(または WebGPU)',
    'web-audio': 'キー音と BGM の再生',
    'file-api': 'ドラッグ&ドロップで BMS フォルダと LR2 テーマを読み込む',
    webassembly: 'BGA 動画の変換(ffmpeg.wasm)',
    worker: 'メインスレッドの外で BGA を変換する',
    webgpu: '優先する GPU 経路。使えなければ WebGL2',
    webcodecs: 'ハードウェアによる BGA のエンコード',
    'media-recorder': 'プレイを WebM で録画',
    'offscreen-canvas': 'LR2 のビットマップフォント変換',
  },
  account: {
    notSignedIn: 'ログインしていません',
    anonymous: 'ゲスト',
    passkey: (count) => `パスキー ${count}`,
    chipSignedOutTitle: 'Leaderboard にログインしていません。Options の Leaderboard からログインできます。',
    chipAnonymousTitle:
      'ゲストでログイン中です。パスキー・Google・Discord のどれかで保存すると、このアカウントとプレイを Leaderboard に残せます。',
    chipSignedInTitle: (name, handle) => `${name}(@${handle})でログイン中です。Leaderboard のページを開きます。`,
    startSignedOutHint: 'プレイを送る前に Accounts でログインしてください。ゲストアカウントから始められます。',
    startAnonymousHint:
      'ゲストアカウントはランキングに出ず、ほかの端末からはログインできません。パスキー・Google・Discord のどれかで保存すると載ります。',
    signUp: '登録',
    signIn: 'ログイン',
    signInLead: 'パスキー、Google、Discord のどれかでログインすると、プレイを送れます。',
    signInPasskey: 'パスキーでログイン',
    signInGoogle: 'Google でログイン',
    signInDiscord: 'Discord でログイン',
    or: 'または',
    noAccount: 'アカウントがまだない場合',
    signedInLead: 'プレイはこのアカウントに送ります。',
    myPage: 'マイページ',
    anonymousLead:
      'ゲストでログインしています。このアカウントを保存するとランキングに載ります。別のアカウントでのログインもできます。',
    keep: 'このアカウントを保存',
    signOut: 'ログアウト',
    manage: 'アカウント管理',
    signInFailed: 'ログインできませんでした',
    signUpFailed: '登録できませんでした',
    couldNotSignOut: 'ログアウトできませんでした。',
    accountReadyPrefix: 'アカウントを作成しました',
    handleReserved: 'このユーザー名は使えません。別のユーザー名を選んでください。',
    handleFormat: 'ユーザー名は英数字と _ で 3〜15 文字です。',
    nameEmpty: '表示名を入力してください。',
    nameLength: '表示名は 32 文字までです。',
    nameCharacters: '表示名に改行や制御文字は使えません。',
    handleTaken: 'このユーザー名はすでに使われています。',
    signInFirst: '先にログインしてください。',
    somethingWrong: (error) => `問題が発生しました(${error})。`,
  },
  record: {
    full: '記録: スコア、ランプ、プレイ回数を保存します · Leaderboard: メインボード',
    assisted: (assistClass, lamp, options) =>
      `${assistClass}(${options}): ${lamp}とプレイ回数のみ、スコアは保存しません · Leaderboard: アシストボード`,
    notSaved: (options) => `保存しません(${options}): 記録なし · Leaderboard: 保存のみ、ランキング外`,
    conditional: (options, consequence) => `— ${options} が譜面を変える場合: ${consequence}`,
    autoPlay: 'オートプレイ: 記録なし、Leaderboard にも送りません',
    twoPlayer: '2 人プレイの BATTLE: リプレイは残り、記録とランキングは残りません',
    bmsonTotal: 'bmson の TOTAL 0 で回復なし: 記録なし · Leaderboard: 保存のみ、ランキング外',
    lampKept: 'ランプ',
    lampCap: (lamp) => `ランプ(${lamp} まで)`,
    lampReplace: (lamp) => `${lamp} ランプ`,
    separateLamp: (slot) => `(${slot} として別に保存)`,
    classes: { light: 'LIGHT ASSIST', assist: 'ASSIST' },
    slots: { 'd-battle': 'D-BATTLE', 'sp-to-dp': 'SP TO DP', extra: 'EXTRA MODE' },
    board: { main: 'メインボード', assisted: 'アシストボード' },
  },
  replay: {
    invalid: (message) => `リプレイ: 不正なリプレイです(${message})`,
    notLoaded: (title) => `リプレイ: 譜面が読み込まれていません(${title})`,
    untitled: '無題',
    loadChart: 'この譜面を読み込んでから、リプレイをもう一度ドロップしてください。',
    replaying: (title) => `リプレイ中: ${title}`,
    failed: (message) => `リプレイに失敗しました: ${message}`,
    slotUnreadable: (slot) => `リプレイスロット ${slot} を読めませんでした`,
    replayingSlot: (slot, title) => `スロット ${slot} をリプレイ中: ${title}`,
    slotDeleted: (slot) => `リプレイスロット ${slot} を空にしました`,
    slotNotDeleted: (slot) => `リプレイスロット ${slot} を削除できませんでした`,
    invalidCourse: (message) => `コースリプレイ: 不正なコースリプレイです(${message})`,
    stagesMissing: (missing, total) => `コースリプレイ: ${total} ステージ中 ${missing} の譜面が読み込まれていません`,
    loadStages: (name) => `${name} のこれらの譜面を読み込んでから、コースリプレイをもう一度ドロップしてください。`,
    courseFailed: (message) => `コースリプレイに失敗しました: ${message}`,
    untitledChart: '無題の譜面',
    slotsTitle: 'リプレイスロット',
    slotsAndHistory: 'リプレイスロットと履歴',
    historyTitle: 'リプレイ履歴',
    allHistory: 'すべての譜面・コースを表示',
    emptyHistory: 'リプレイ履歴はありません。',
    loadingHistory: 'リプレイ履歴を読み込んでいます…',
    historyUnreadable: 'このリプレイを読み込めませんでした。',
    historyDeleted: 'リプレイを履歴から削除しました。',
    historyNotDeleted: 'リプレイを削除できませんでした。',
    confirmDeleteHistory: (title) => `「${title}」のリプレイを履歴から削除し、選択しているスロットを空にしますか?`,
    clearSlot: 'スロットを空にする',
    confirmClearSlot: (slot, title) => `「${title}」のスロット ${slot} を空にしますか? リプレイは履歴に残ります。`,
    save: '保存',
    saved: '保存済み',
    savedNow: 'いま保存しました',
    empty: '空',
    slot: (slot) => `スロット ${slot}`,
    saveHint: 'このプレイをスロットに割り当てます(キー 1〜4)。各スロットには履歴のリプレイを1件選べます。',
    cannotSave: 'このプレイはスロットに保存できません。',
    replay: 'リプレイ',
    download: 'ダウンロード',
    delete: '削除',
  },
  lb: {
    notSubmitted: (error) => `Leaderboard: 送信しませんでした(${error})`,
    courseNotSubmitted: (error) => `Leaderboard: コースを送信しませんでした(${error})`,
    network: 'Leaderboard: 送信しませんでした(ネットワークエラー)',
    courseNetwork: 'Leaderboard: コースを送信しませんでした(ネットワークエラー)',
    notImproved: 'Leaderboard: 送信しませんでした(EX-SCORE の更新なし)',
    stored: (reason, again) => `Leaderboard: 保存しましたがランキング外です(${reason})${again}`,
    submitted: 'Leaderboard: 送信しました',
    ranked: (ruleset, rank, players, exScore, best, again) =>
      `Leaderboard ${ruleset}: #${rank} / ${players} · EX ${exScore}${best}${again}`,
    courseRanked: (ruleset, rank, players, exScore, best, again) =>
      `Leaderboard コース ${ruleset}: #${rank} / ${players} · EX ${exScore}${best}${again}`,
    already: '(送信済み)',
    newBest: (parts) => ` · 自己ベスト更新 ${parts}`,
    notSimulated: (rulesets) => ` · ${rulesets} では判定できません`,
    truncated: (rulesets) => ` · ${rulesets} では失敗した所までを判定`,
    lamp: 'ランプ',
    unranked: {
      'bmson-total': 'bmson の TOTAL 0 で回復なし',
      tempo: '別のテンポでのプレイは練習です',
      'course-stage': 'コースの 1 ステージはコースといっしょに順位が付きます',
      'no-save': '記録を保存しないオプションを使いました',
      unreleased: '自作コースは IR に登録するまで、ランダムコースは常にランキングに入りません',
    },
    skipped: {
      'two-player': 'Leaderboard: 送信しませんでした(2 人プレイには 1 人用の順位がありません)',
      'auto-play': 'Leaderboard: 送信しませんでした(オートプレイは送りません)',
      'missing-fingerprint': 'Leaderboard: 送信しませんでした(このリプレイに譜面フィンガープリントがありません)',
      'fingerprint-mismatch': 'Leaderboard: 送信しませんでした(譜面が記録されたプレイと一致しません)',
    },
    courseSkipped: {
      'two-player': 'Leaderboard: コースを送信しませんでした(2 人プレイには 1 人用の順位がありません)',
      'auto-play': 'Leaderboard: コースを送信しませんでした(オートプレイは送りません)',
      aborted: 'Leaderboard: コースを送信しませんでした(最後より前のステージでリタイアしています)',
      'not-a-course-run': 'Leaderboard: コースを送信しませんでした(ステージが 1 回のコースランになっていません)',
      'missing-fingerprint':
        'Leaderboard: コースを送信しませんでした(ステージの譜面にフィンガープリントがありません)',
      'fingerprint-mismatch':
        'Leaderboard: コースを送信しませんでした(ステージの譜面が記録されたプレイと一致しません)',
    },
  },
  course: {
    making: 'コースを作成中: 譜面を決定して追加し、保存してください',
    newCourse: (kind) => `新しい ${kind} コース`,
    decideCharts: '決定すると譜面を追加します(最大 5 譜面、最初の譜面のモード)。',
    chartCount: (count) => `${count} / 5 譜面`,
    courseName: 'コース名',
    connection: '接続',
    removeLast: '最後を外す',
    save: '保存',
    stopped: 'コースの作成をやめました',
    saved: (name) => `コース「${name}」を保存しました`,
    added: (title, count) => `${title} をコースに追加しました(${count} / 5)`,
    couldNotAdd: (title, reason) => `${title} を追加できませんでした: ${reason}`,
    addReasons: {
      full: 'コースはすでに 5 譜面です',
      'key-mode': '最初の譜面とモードが違います',
      'no-md5': '譜面のハッシュを計算できませんでした',
      'not-making': 'コースを作成していません',
    },
    unsaved: 'このブラウザにコースを保存できませんでした。ページを閉じるまで残ります',
    empty: 'コースはまだありません。コースフォルダで NEW COURSE を決定すると作れます。',
    exportLr2: '.lr2crs を書き出す',
    exportBeatoraja: 'beatoraja .json を書き出す',
    myCourses: 'マイコース',
    myCoursesLead: 'このブラウザに保存した、自分で作ったコースです。',
    delete: '削除',
    confirmDelete: (name) => `コース「${name}」を削除しますか?`,
    registerIR: 'IR に登録',
    confirmIR: (name) =>
      `コース「${name}」を IR に登録しますか? 登録するとランキングに入り、つなぎ方と制限は変更できなくなります。取り消せません。`,
    irOn: 'IR ON: ランキング対象。つなぎ方と制限は変更できません',
    close: '閉じる',
    stageMissing: (name, count) => `${name}: ${count} ステージがコレクションにありません`,
    missingStages: {
      title: 'ステージがありません',
      hint: (name) => `${name} を遊ぶには次の譜面が必要です。ページを開いてダウンロードし、読み込んでください。`,
      stage: (stage) => `ステージ ${stage}`,
      looking: 'ダウンロードページを探しています…',
      noLink: 'ダウンロードページが載っていません',
      song: '本体',
      diff: '差分',
      pack: 'パック',
    },
    randomNoChart: (name, stage) => `${name}: ステージ ${stage} に一致する譜面がありません`,
    randomBadFilter: (name, stage, error) => `${name}: ステージ ${stage} のフィルタが不正です(${error})`,
    nonstopLayout: (name, stage) => `${name}: NONSTOP の全ステージは同じ汎用キーボード配置である必要があります${stage}`,
    nonstopStitch: (name, reason, stage) => `${name}: NONSTOP コースを繋げません: ${reason}${stage}`,
    nonstopLRXMixed: (name, stage) => `${name}: NONSTOP コースでは LRX 譜面と BMS・bmson 譜面を混ぜられません${stage}`,
    nonstopLRXLayout: (name, stage) =>
      `${name}: NONSTOP コースの LRX ステージはすべて同じレーン構成である必要があります${stage}`,
    stageNote: (stage) => `(ステージ ${stage})`,
    constraints: {
      option: 'レーンオプション',
      speed: 'ハイスピード',
      judge: '判定',
      gauge: 'ゲージ',
      longNote: 'ロングノート',
    },
    choices: {
      free: '制限なし',
      normal: '通常',
      offOnly: 'OFF のみ(CLASS)',
      offOrMirror: 'OFF または MIRROR',
      randomFamily: 'ランダム系',
      locked: '固定',
      noGreat: 'GREAT なし',
      noGood: 'GOOD なし',
      playersChoice: 'プレイヤーの選択',
      keys5: '5 鍵',
      keys7: '7 鍵',
      keys9: '9 鍵',
      keys24: '24 鍵',
      asCharted: '譜面どおり',
    },
    randomMix: {
      preferredLevel: '好みのレベル',
      bpmRange: 'BPM の幅',
      maxBPM: '最大 BPM',
      minBPM: '最小 BPM',
    },
    randomMixDialog: {
      title: 'RANDOM MIX',
      hint: '抽選する譜面の条件を選び、OK で始めます。',
      keys: 'キー',
      keyMode: (keyMode) => `${keyMode} KEYS`,
      narrowBy: '絞り込み',
      byLevel: 'レベル',
      byDifficulty: '難易度',
      minLevel: '最小レベル',
      maxLevel: '最大レベル',
      anyLevel: '指定なし',
      difficulty: '難易度',
      estimateDifficulty: '#DIFFICULTY がない譜面は推定する',
      allowBPMChanges: 'BPM が途中で変わる譜面も選ぶ',
      count: '曲数',
      settings: '抽選の設定',
      defaultConnection: 'つなぎ方',
      infinity: '無限',
      nonstopNoInfinity: 'NONSTOP は開始前に全ステージをつなぐため、無限にはできません。',
      matches: (count) => `${count} 譜面が条件に合います。`,
      noMatch: '条件に合う譜面がありません。',
      noFirstStage: (count) =>
        `${count} 譜面が条件に合いますが、抽選の設定では 1 曲目にできる譜面がありません。BPM が途中で変わる譜面を選ばない設定で BPM の範囲を設定していると、1 曲目は BPM が変わらない譜面に限られ、最大 / 最小 BPM も効きます。BPM が途中で変わる譜面も選ぶか、BPM の範囲を NO LIMIT にするか、BPM の制限を広げてください。`,
      cancel: 'キャンセル',
      ok: 'OK',
    },
    randomMixSave: {
      title: 'この RANDOM MIX を保存しますか?',
      hint: '選ばれた譜面を自分のコースとして保存します。下の設定はこの譜面を選んだ設定で、ここでは変更できません。',
      name: 'コース名',
      stages: (count) => `${count} ステージ`,
      settings: '開始時の設定',
      settingsFixed: 'RANDOM MIX を開始したときの設定です。',
      kind: 'コース',
      on: 'オン',
      off: 'オフ',
      none: 'なし',
      discard: '保存しない',
      save: '保存',
    },
    randomMixNoMatch: 'RANDOM MIX: 条件に合う譜面がありません',
  },
  practice: {
    title: 'PRACTICE',
    lead: '小節を押すとその小節を試聴します。Shift を押しながら押すかドラッグすると連続した小節を選べます。「練習を始める」で選んだ小節をループします。',
    wholeChart: '小節を選んでいません。譜面全体をループします',
    bars: (first, last, from, to) =>
      first === last ? `小節 ${first} · ${from} → ${to}` : `小節 ${first}–${last} · ${from} → ${to}`,
    start: '練習を始める',
    playNormally: '練習せずに遊ぶ',
    clear: '譜面全体',
    cancel: 'キャンセル',
    loading: '譜面を読んでいます…',
    unreadable: 'この譜面には表示できる小節がありません。「練習を始める」で譜面全体をループします。',
  },
  camera: {
    defaultCamera: '既定のカメラ',
    unnamed: (index) => `カメラ ${index}`,
    missingChoice: (label) => `${label}(未接続)`,
    previewLabel: 'カメラのプレビュー',
    previewOff:
      '「BGA の枠にカメラを映す」をオンにすると、ここにカメラの映像が出ます。このタブを離れるとプレビューは止まります。',
    status: {
      off: 'オフ。BGA の枠には譜面の BGA を映します。',
      standby: 'オン。プレイが始まるとカメラを起動します。',
      starting: 'カメラを起動しています…',
      live: 'BGA の枠にカメラの映像を映しています。',
      denied:
        'カメラへのアクセスがブロックされています。ブラウザのサイト設定で許可してから「カメラへのアクセスを許可」を押してください。',
      missing: 'カメラがつながっていません。つながるまでプレイでは BGA を映します。',
      busy: 'カメラを起動できませんでした(ほかのアプリが使っているかもしれません)。',
      unsupported: 'このブラウザでは、このページからカメラを使えません。',
    },
    needNames: 'カメラを名前で選ぶには、一度「カメラへのアクセスを許可」を押してください。',
    privacy: '映像はこの端末の外に出ません。Capture で録画すると、BGA の枠ごと映像も記録されます。',
    lost: {
      denied: 'カメラへのアクセスが拒否されました。BGA を映します。',
      missing: 'カメラがつながっていません。BGA を映します。',
      busy: 'カメラを起動できませんでした。BGA を映します。',
      unsupported: 'このブラウザではカメラを使えません。BGA を映します。',
    },
  },
  embed: {
    needTrack: 'プレビューするには、譜面アーカイブ(.zip)の URL を ?track= に指定してください。',
    loadFailed: (message) => `楽曲を読み込めませんでした: ${message}`,
    noChart: 'この楽曲にプレイできる譜面がありません。',
    noStage: 'このコースにプレイできるステージがありません。',
    loadingTrack: '楽曲を読み込み中',
    downloading: (size) => `楽曲をダウンロードしています… ${size}`,
    reading: (current, total) => (total > 0 ? `譜面を読んでいます… ${current} / ${total}` : '譜面を読んでいます…'),
    badCourseFile: 'LR2 の .lr2crs か beatoraja の .json コースファイルを選んでください。',
  },
};
 
const CATALOGS = { en, ja } as const;
 
export type PlayerCopy = typeof en;
 
let lang: PlayerLang = 'en';
 
const langListeners = new Set<() => void>();
 
/** Runs after {@link setPlayerLang} has written the new copy, so views built in code can rebuild. */
export function onPlayerLangChange(listener: () => void): () => void {
  langListeners.add(listener);
  return () => {
    langListeners.delete(listener);
  };
}
 
export function playerLang(): PlayerLang {
  return lang;
}
 
export function playerText(): PlayerCopy {
  return CATALOGS[lang];
}
 
/** The language a browser reports, English when there is none (tests, workers). */
export function detectPlayerLang(): PlayerLang {
  return typeof navigator === 'undefined' ? 'en' : resolvePlayerLang(navigator.language);
}
 
/** Selects the document language and notifies the bindings that own localized content. */
export function setPlayerLang(next: PlayerLang): void {
  lang = next;
  if (typeof document !== 'undefined') document.documentElement.lang = next;
  for (const listener of langListeners) listener();
}