react-cheminfo 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -2
- package/bin/check-messages.mjs +229 -0
- package/lib/about/ui/AboutBuild.d.ts.map +1 -1
- package/lib/about/ui/AboutBuild.js +15 -4
- package/lib/about/ui/AboutBuild.js.map +1 -1
- package/lib/about/ui/AboutCitations.d.ts.map +1 -1
- package/lib/about/ui/AboutCitations.js +3 -1
- package/lib/about/ui/AboutCitations.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +9 -1
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutProvidedBy.d.ts.map +1 -1
- package/lib/about/ui/AboutProvidedBy.js +8 -3
- package/lib/about/ui/AboutProvidedBy.js.map +1 -1
- package/lib/capsule/ui/Capsule.d.ts +30 -0
- package/lib/capsule/ui/Capsule.d.ts.map +1 -0
- package/lib/capsule/ui/Capsule.js +12 -0
- package/lib/capsule/ui/Capsule.js.map +1 -0
- package/lib/capsule/ui/CapsuleFilter.d.ts +19 -3
- package/lib/capsule/ui/CapsuleFilter.d.ts.map +1 -1
- package/lib/capsule/ui/CapsuleFilter.js +14 -44
- package/lib/capsule/ui/CapsuleFilter.js.map +1 -1
- package/lib/capsule/ui/capsuleFilterCapsules.d.ts +15 -0
- package/lib/capsule/ui/capsuleFilterCapsules.d.ts.map +1 -0
- package/lib/capsule/ui/capsuleFilterCapsules.js +47 -0
- package/lib/capsule/ui/capsuleFilterCapsules.js.map +1 -0
- package/lib/chart/ui/ChartTrackingLayer.d.ts.map +1 -1
- package/lib/chart/ui/ChartTrackingLayer.js +4 -2
- package/lib/chart/ui/ChartTrackingLayer.js.map +1 -1
- package/lib/chrome/ui/SiteHeader.d.ts +1 -1
- package/lib/chrome/ui/SiteHeader.d.ts.map +1 -1
- package/lib/chrome/ui/SiteHeader.js +4 -2
- package/lib/chrome/ui/SiteHeader.js.map +1 -1
- package/lib/citation/ui/CitationMenu.d.ts +1 -1
- package/lib/citation/ui/CitationMenu.d.ts.map +1 -1
- package/lib/citation/ui/CitationMenu.js +7 -3
- package/lib/citation/ui/CitationMenu.js.map +1 -1
- package/lib/citation/ui/CiteButton.d.ts +1 -1
- package/lib/citation/ui/CiteButton.d.ts.map +1 -1
- package/lib/citation/ui/CiteButton.js +3 -1
- package/lib/citation/ui/CiteButton.js.map +1 -1
- package/lib/citation/ui/CopyFormatEntries.d.ts.map +1 -1
- package/lib/citation/ui/CopyFormatEntries.js +3 -1
- package/lib/citation/ui/CopyFormatEntries.js.map +1 -1
- package/lib/citation/ui/WorkEntry.d.ts.map +1 -1
- package/lib/citation/ui/WorkEntry.js +3 -1
- package/lib/citation/ui/WorkEntry.js.map +1 -1
- package/lib/citation/ui/entries.d.ts.map +1 -1
- package/lib/citation/ui/entries.js +8 -2
- package/lib/citation/ui/entries.js.map +1 -1
- package/lib/citation/ui/useCopyFeedback.d.ts.map +1 -1
- package/lib/citation/ui/useCopyFeedback.js +9 -4
- package/lib/citation/ui/useCopyFeedback.js.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.js +12 -6
- package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
- package/lib/clipboard/ui/CopyButton.d.ts +3 -3
- package/lib/clipboard/ui/CopyButton.d.ts.map +1 -1
- package/lib/clipboard/ui/CopyButton.js +7 -4
- package/lib/clipboard/ui/CopyButton.js.map +1 -1
- package/lib/color/ui/ColorScaleEditor.d.ts.map +1 -1
- package/lib/color/ui/ColorScaleEditor.js +15 -10
- package/lib/color/ui/ColorScaleEditor.js.map +1 -1
- package/lib/color/ui/ColorScaleEntry.d.ts.map +1 -1
- package/lib/color/ui/ColorScaleEntry.js +4 -2
- package/lib/color/ui/ColorScaleEntry.js.map +1 -1
- package/lib/color/ui/ColorScaleLegend.d.ts.map +1 -1
- package/lib/color/ui/ColorScaleLegend.js +7 -1
- package/lib/color/ui/ColorScaleLegend.js.map +1 -1
- package/lib/color/ui/ColorScaleSelect.d.ts.map +1 -1
- package/lib/color/ui/ColorScaleSelect.js +8 -4
- package/lib/color/ui/ColorScaleSelect.js.map +1 -1
- package/lib/confirm/ui/ConfirmButton.d.ts +2 -2
- package/lib/confirm/ui/ConfirmButton.d.ts.map +1 -1
- package/lib/confirm/ui/ConfirmButton.js +4 -2
- package/lib/confirm/ui/ConfirmButton.js.map +1 -1
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/ui/CreditsList.d.ts.map +1 -1
- package/lib/credits/ui/CreditsList.js +3 -1
- package/lib/credits/ui/CreditsList.js.map +1 -1
- package/lib/delimited/ui/DelimitedTextDialog.d.ts.map +1 -1
- package/lib/delimited/ui/DelimitedTextDialog.js +5 -2
- package/lib/delimited/ui/DelimitedTextDialog.js.map +1 -1
- package/lib/delimited/ui/DelimitedTextPanel.d.ts.map +1 -1
- package/lib/delimited/ui/DelimitedTextPanel.js +8 -8
- package/lib/delimited/ui/DelimitedTextPanel.js.map +1 -1
- package/lib/download/ui/FigureDownload.d.ts +2 -2
- package/lib/download/ui/FigureDownload.d.ts.map +1 -1
- package/lib/download/ui/FigureDownload.js +4 -2
- package/lib/download/ui/FigureDownload.js.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +24 -18
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemButton.d.ts +1 -1
- package/lib/ecosystem/ui/EcosystemButton.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemButton.js +4 -2
- package/lib/ecosystem/ui/EcosystemButton.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.d.ts +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.js +5 -2
- package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemMenu.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemMenu.js +3 -1
- package/lib/ecosystem/ui/EcosystemMenu.js.map +1 -1
- package/lib/ecosystem/ui/SiteGroupSection.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteGroupSection.js +3 -1
- package/lib/ecosystem/ui/SiteGroupSection.js.map +1 -1
- package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTile.js +3 -1
- package/lib/ecosystem/ui/SiteTile.js.map +1 -1
- package/lib/error/ui/ErrorFallback.d.ts +2 -2
- package/lib/error/ui/ErrorFallback.d.ts.map +1 -1
- package/lib/error/ui/ErrorFallback.js +4 -2
- package/lib/error/ui/ErrorFallback.js.map +1 -1
- package/lib/help/ui/HelpBody.d.ts.map +1 -1
- package/lib/help/ui/HelpBody.js +3 -1
- package/lib/help/ui/HelpBody.js.map +1 -1
- package/lib/help/ui/HelpIcon.d.ts +2 -1
- package/lib/help/ui/HelpIcon.d.ts.map +1 -1
- package/lib/help/ui/HelpIcon.js +4 -2
- package/lib/help/ui/HelpIcon.js.map +1 -1
- package/lib/help/ui/HelpToolbarButton.d.ts.map +1 -1
- package/lib/help/ui/HelpToolbarButton.js +3 -1
- package/lib/help/ui/HelpToolbarButton.js.map +1 -1
- package/lib/help/ui/helpName.d.ts +5 -1
- package/lib/help/ui/helpName.d.ts.map +1 -1
- package/lib/help/ui/helpName.js +4 -2
- package/lib/help/ui/helpName.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +21 -0
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -0
- package/lib/i18n/core/chromeCatalog.js +29 -0
- package/lib/i18n/core/chromeCatalog.js.map +1 -0
- package/lib/i18n/core/index.d.ts +12 -0
- package/lib/i18n/core/index.d.ts.map +1 -0
- package/lib/i18n/core/index.js +6 -0
- package/lib/i18n/core/index.js.map +1 -0
- package/lib/i18n/core/languages.d.ts +32 -0
- package/lib/i18n/core/languages.d.ts.map +1 -0
- package/lib/i18n/core/languages.js +41 -0
- package/lib/i18n/core/languages.js.map +1 -0
- package/lib/i18n/core/messageCatalog.d.ts +113 -0
- package/lib/i18n/core/messageCatalog.d.ts.map +1 -0
- package/lib/i18n/core/messageCatalog.js +135 -0
- package/lib/i18n/core/messageCatalog.js.map +1 -0
- package/lib/i18n/core/messageValues.d.ts +3 -0
- package/lib/i18n/core/messageValues.d.ts.map +1 -0
- package/lib/i18n/core/messageValues.js +2 -0
- package/lib/i18n/core/messageValues.js.map +1 -0
- package/lib/i18n/core/session.d.ts +51 -0
- package/lib/i18n/core/session.d.ts.map +1 -0
- package/lib/i18n/core/session.js +64 -0
- package/lib/i18n/core/session.js.map +1 -0
- package/lib/i18n/core/translateSetup.d.ts +28 -0
- package/lib/i18n/core/translateSetup.d.ts.map +1 -0
- package/lib/i18n/core/translateSetup.js +30 -0
- package/lib/i18n/core/translateSetup.js.map +1 -0
- package/lib/i18n/ui/LanguageSelect.d.ts +37 -0
- package/lib/i18n/ui/LanguageSelect.d.ts.map +1 -0
- package/lib/i18n/ui/LanguageSelect.js +27 -0
- package/lib/i18n/ui/LanguageSelect.js.map +1 -0
- package/lib/i18n/ui/index.d.ts +6 -0
- package/lib/i18n/ui/index.d.ts.map +1 -0
- package/lib/i18n/ui/index.js +4 -0
- package/lib/i18n/ui/index.js.map +1 -0
- package/lib/i18n/ui/useLanguage.d.ts +23 -0
- package/lib/i18n/ui/useLanguage.d.ts.map +1 -0
- package/lib/i18n/ui/useLanguage.js +36 -0
- package/lib/i18n/ui/useLanguage.js.map +1 -0
- package/lib/i18n/ui/useT.d.ts +47 -0
- package/lib/i18n/ui/useT.d.ts.map +1 -0
- package/lib/i18n/ui/useT.js +51 -0
- package/lib/i18n/ui/useT.js.map +1 -0
- package/lib/locales/de.json +442 -0
- package/lib/locales/en.json +442 -0
- package/lib/locales/es.json +442 -0
- package/lib/locales/fr.json +442 -0
- package/lib/molecule3d/core/gestures.d.ts +10 -0
- package/lib/molecule3d/core/gestures.d.ts.map +1 -1
- package/lib/molecule3d/core/gestures.js +39 -7
- package/lib/molecule3d/core/gestures.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DExport.js +3 -1
- package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DHelp.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DHelp.js +7 -2
- package/lib/molecule3d/ui/Molecule3DHelp.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DOptions.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DOptions.js +9 -9
- package/lib/molecule3d/ui/Molecule3DOptions.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DSurfaceColors.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DSurfaceColors.js +8 -8
- package/lib/molecule3d/ui/Molecule3DSurfaceColors.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.js +15 -10
- package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeViewer3D.js +6 -3
- package/lib/molecule3d/ui/MoleculeViewer3D.js.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalCanvas.js +3 -1
- package/lib/orbital/ui/AtomicOrbitalCanvas.js.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalControls.d.ts.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalControls.js +12 -15
- package/lib/orbital/ui/AtomicOrbitalControls.js.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalViewer.d.ts.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalViewer.js +6 -3
- package/lib/orbital/ui/AtomicOrbitalViewer.js.map +1 -1
- package/lib/orbital/ui/capability.d.ts +4 -0
- package/lib/orbital/ui/capability.d.ts.map +1 -1
- package/lib/orbital/ui/capability.js +4 -0
- package/lib/orbital/ui/capability.js.map +1 -1
- package/lib/overlay/ui/OverlayBar.d.ts +1 -1
- package/lib/overlay/ui/OverlayBar.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayBar.js +6 -3
- package/lib/overlay/ui/OverlayBar.js.map +1 -1
- package/lib/overlay/ui/OverlayInfo.d.ts +1 -1
- package/lib/overlay/ui/OverlayInfo.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayInfo.js +5 -2
- package/lib/overlay/ui/OverlayInfo.js.map +1 -1
- package/lib/overlay/ui/OverlayPanel.d.ts +9 -2
- package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayPanel.js +5 -11
- package/lib/overlay/ui/OverlayPanel.js.map +1 -1
- package/lib/overlay/ui/OverlayReadout.d.ts.map +1 -1
- package/lib/overlay/ui/OverlayReadout.js +3 -1
- package/lib/overlay/ui/OverlayReadout.js.map +1 -1
- package/lib/pedagogy/ui/ExerciseActions.d.ts +1 -1
- package/lib/pedagogy/ui/ExerciseActions.d.ts.map +1 -1
- package/lib/pedagogy/ui/ExerciseActions.js +9 -2
- package/lib/pedagogy/ui/ExerciseActions.js.map +1 -1
- package/lib/pedagogy/ui/ExerciseProgressHeader.d.ts +1 -1
- package/lib/pedagogy/ui/ExerciseProgressHeader.d.ts.map +1 -1
- package/lib/pedagogy/ui/ExerciseProgressHeader.js +9 -5
- package/lib/pedagogy/ui/ExerciseProgressHeader.js.map +1 -1
- package/lib/pedagogy/ui/GlossaryIndex.d.ts +1 -1
- package/lib/pedagogy/ui/GlossaryIndex.d.ts.map +1 -1
- package/lib/pedagogy/ui/GlossaryIndex.js +6 -8
- package/lib/pedagogy/ui/GlossaryIndex.js.map +1 -1
- package/lib/pedagogy/ui/HintLadder.d.ts +2 -2
- package/lib/pedagogy/ui/HintLadder.d.ts.map +1 -1
- package/lib/pedagogy/ui/HintLadder.js +8 -2
- package/lib/pedagogy/ui/HintLadder.js.map +1 -1
- package/lib/pedagogy/ui/SyntaxTooltip.d.ts +4 -4
- package/lib/pedagogy/ui/SyntaxTooltip.d.ts.map +1 -1
- package/lib/pedagogy/ui/SyntaxTooltip.js +4 -2
- package/lib/pedagogy/ui/SyntaxTooltip.js.map +1 -1
- package/lib/pedagogy/ui/TutorialStepStrip.d.ts.map +1 -1
- package/lib/pedagogy/ui/TutorialStepStrip.js +7 -2
- package/lib/pedagogy/ui/TutorialStepStrip.js.map +1 -1
- package/lib/periodic/ui/CategoryLegend.d.ts.map +1 -1
- package/lib/periodic/ui/CategoryLegend.js +3 -1
- package/lib/periodic/ui/CategoryLegend.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +7 -1
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +3 -1
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.js +4 -2
- package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
- package/lib/share/ui/ShareButton.d.ts +2 -2
- package/lib/share/ui/ShareButton.d.ts.map +1 -1
- package/lib/share/ui/ShareButton.js +5 -2
- package/lib/share/ui/ShareButton.js.map +1 -1
- package/lib/share/ui/ShareConfigOptions.d.ts.map +1 -1
- package/lib/share/ui/ShareConfigOptions.js +4 -2
- package/lib/share/ui/ShareConfigOptions.js.map +1 -1
- package/lib/share/ui/ShareDialog.d.ts.map +1 -1
- package/lib/share/ui/ShareDialog.js +3 -1
- package/lib/share/ui/ShareDialog.js.map +1 -1
- package/lib/share/ui/ShareDialogContent.d.ts.map +1 -1
- package/lib/share/ui/ShareDialogContent.js +10 -1
- package/lib/share/ui/ShareDialogContent.js.map +1 -1
- package/lib/share/ui/SharePresetTabs.d.ts.map +1 -1
- package/lib/share/ui/SharePresetTabs.js +3 -1
- package/lib/share/ui/SharePresetTabs.js.map +1 -1
- package/lib/slides/ui/BackToSlides.d.ts.map +1 -1
- package/lib/slides/ui/BackToSlides.js +4 -2
- package/lib/slides/ui/BackToSlides.js.map +1 -1
- package/lib/slides/ui/EmbedSlide.d.ts.map +1 -1
- package/lib/slides/ui/EmbedSlide.js +3 -1
- package/lib/slides/ui/EmbedSlide.js.map +1 -1
- package/lib/slides/ui/Slide.d.ts.map +1 -1
- package/lib/slides/ui/Slide.js +3 -1
- package/lib/slides/ui/Slide.js.map +1 -1
- package/lib/slides/ui/SlideshowBar.d.ts.map +1 -1
- package/lib/slides/ui/SlideshowBar.js +5 -3
- package/lib/slides/ui/SlideshowBar.js.map +1 -1
- package/lib/slides/ui/TalkList.d.ts +1 -1
- package/lib/slides/ui/TalkList.d.ts.map +1 -1
- package/lib/slides/ui/TalkList.js +4 -2
- package/lib/slides/ui/TalkList.js.map +1 -1
- package/lib/structure/core/editorGuide.d.ts +14 -0
- package/lib/structure/core/editorGuide.d.ts.map +1 -1
- package/lib/structure/core/editorGuide.js +117 -19
- package/lib/structure/core/editorGuide.js.map +1 -1
- package/lib/structure/core/editorToolbar.d.ts +3 -1
- package/lib/structure/core/editorToolbar.d.ts.map +1 -1
- package/lib/structure/core/editorToolbar.js +44 -23
- package/lib/structure/core/editorToolbar.js.map +1 -1
- package/lib/structure/ui/EditorHelpButton.d.ts.map +1 -1
- package/lib/structure/ui/EditorHelpButton.js +3 -2
- package/lib/structure/ui/EditorHelpButton.js.map +1 -1
- package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
- package/lib/structure/ui/StructureEditor.js +3 -1
- package/lib/structure/ui/StructureEditor.js.map +1 -1
- package/lib/structure/ui/StructureEditorHelp.d.ts.map +1 -1
- package/lib/structure/ui/StructureEditorHelp.js +12 -3
- package/lib/structure/ui/StructureEditorHelp.js.map +1 -1
- package/lib/structure/ui/ToolbarTooltip.d.ts.map +1 -1
- package/lib/structure/ui/ToolbarTooltip.js +5 -3
- package/lib/structure/ui/ToolbarTooltip.js.map +1 -1
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/package.json +4 -2
- package/src/about/ui/AboutBuild.tsx +23 -16
- package/src/about/ui/AboutCitations.tsx +3 -1
- package/src/about/ui/AboutPage.tsx +38 -12
- package/src/about/ui/AboutProvidedBy.tsx +13 -3
- package/src/capsule/ui/Capsule.tsx +48 -0
- package/src/capsule/ui/CapsuleFilter.tsx +38 -114
- package/src/capsule/ui/capsuleFilterCapsules.tsx +110 -0
- package/src/chart/ui/ChartTrackingLayer.tsx +4 -2
- package/src/chrome/ui/SiteHeader.tsx +5 -3
- package/src/citation/ui/CitationMenu.tsx +9 -5
- package/src/citation/ui/CiteButton.tsx +4 -2
- package/src/citation/ui/CopyFormatEntries.tsx +3 -1
- package/src/citation/ui/WorkEntry.tsx +5 -3
- package/src/citation/ui/entries.tsx +9 -2
- package/src/citation/ui/useCopyFeedback.ts +11 -4
- package/src/clipboard/ui/ClickToCopy.tsx +15 -5
- package/src/clipboard/ui/CopyButton.tsx +14 -10
- package/src/color/ui/ColorScaleEditor.tsx +17 -15
- package/src/color/ui/ColorScaleEntry.tsx +7 -3
- package/src/color/ui/ColorScaleLegend.tsx +7 -1
- package/src/color/ui/ColorScaleSelect.tsx +12 -6
- package/src/confirm/ui/ConfirmButton.tsx +9 -11
- package/src/core.ts +1 -0
- package/src/credits/ui/CreditsList.tsx +5 -1
- package/src/delimited/ui/DelimitedTextDialog.tsx +10 -10
- package/src/delimited/ui/DelimitedTextPanel.tsx +19 -12
- package/src/download/ui/FigureDownload.tsx +7 -5
- package/src/download/ui/FigureDownloadPanel.tsx +31 -25
- package/src/ecosystem/ui/EcosystemButton.tsx +5 -3
- package/src/ecosystem/ui/EcosystemLinks.tsx +10 -10
- package/src/ecosystem/ui/EcosystemMenu.tsx +3 -1
- package/src/ecosystem/ui/SiteGroupSection.tsx +6 -2
- package/src/ecosystem/ui/SiteTile.tsx +6 -2
- package/src/error/ui/ErrorFallback.tsx +13 -12
- package/src/help/ui/HelpBody.tsx +4 -2
- package/src/help/ui/HelpIcon.tsx +6 -3
- package/src/help/ui/HelpToolbarButton.tsx +4 -1
- package/src/help/ui/helpName.ts +10 -2
- package/src/i18n/core/chromeCatalog.ts +35 -0
- package/src/i18n/core/index.ts +26 -0
- package/src/i18n/core/languages.ts +46 -0
- package/src/i18n/core/messageCatalog.ts +202 -0
- package/src/i18n/core/messageValues.ts +2 -0
- package/src/i18n/core/session.ts +82 -0
- package/src/i18n/core/translateSetup.ts +47 -0
- package/src/i18n/ui/LanguageSelect.tsx +72 -0
- package/src/i18n/ui/index.ts +9 -0
- package/src/i18n/ui/useLanguage.ts +48 -0
- package/src/i18n/ui/useT.ts +90 -0
- package/src/locales/de.json +442 -0
- package/src/locales/en.json +442 -0
- package/src/locales/es.json +442 -0
- package/src/locales/fr.json +442 -0
- package/src/molecule3d/core/gestures.ts +44 -7
- package/src/molecule3d/ui/Molecule3DExport.tsx +3 -1
- package/src/molecule3d/ui/Molecule3DHelp.tsx +17 -6
- package/src/molecule3d/ui/Molecule3DOptions.tsx +13 -13
- package/src/molecule3d/ui/Molecule3DSurfaceColors.tsx +16 -13
- package/src/molecule3d/ui/Molecule3DToolbar.tsx +29 -18
- package/src/molecule3d/ui/MoleculeViewer3D.tsx +13 -8
- package/src/orbital/ui/AtomicOrbitalCanvas.tsx +3 -1
- package/src/orbital/ui/AtomicOrbitalControls.tsx +15 -20
- package/src/orbital/ui/AtomicOrbitalViewer.tsx +13 -13
- package/src/orbital/ui/capability.ts +10 -0
- package/src/overlay/ui/OverlayBar.tsx +7 -4
- package/src/overlay/ui/OverlayInfo.tsx +6 -3
- package/src/overlay/ui/OverlayPanel.tsx +10 -7
- package/src/overlay/ui/OverlayReadout.tsx +3 -1
- package/src/pedagogy/ui/ExerciseActions.tsx +16 -6
- package/src/pedagogy/ui/ExerciseProgressHeader.tsx +13 -11
- package/src/pedagogy/ui/GlossaryIndex.tsx +11 -12
- package/src/pedagogy/ui/HintLadder.tsx +15 -12
- package/src/pedagogy/ui/SyntaxTooltip.tsx +9 -7
- package/src/pedagogy/ui/TutorialStepStrip.tsx +8 -3
- package/src/periodic/ui/CategoryLegend.tsx +6 -1
- package/src/periodic/ui/ElementCell.tsx +7 -1
- package/src/periodic/ui/PeriodicTable.tsx +3 -1
- package/src/periodic/ui/PeriodicTableChrome.tsx +4 -2
- package/src/share/ui/ShareButton.tsx +8 -5
- package/src/share/ui/ShareConfigOptions.tsx +6 -7
- package/src/share/ui/ShareDialog.tsx +3 -1
- package/src/share/ui/ShareDialogContent.tsx +20 -10
- package/src/share/ui/SharePresetTabs.tsx +3 -1
- package/src/slides/ui/BackToSlides.tsx +4 -2
- package/src/slides/ui/EmbedSlide.tsx +3 -3
- package/src/slides/ui/Slide.tsx +3 -1
- package/src/slides/ui/SlideshowBar.tsx +12 -4
- package/src/slides/ui/TalkList.tsx +8 -10
- package/src/structure/core/editorGuide.ts +126 -19
- package/src/structure/core/editorToolbar.ts +52 -24
- package/src/structure/ui/EditorHelpButton.tsx +9 -4
- package/src/structure/ui/StructureEditor.tsx +7 -1
- package/src/structure/ui/StructureEditorHelp.tsx +34 -11
- package/src/structure/ui/ToolbarTooltip.tsx +8 -4
- package/src/ui.ts +1 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One directory of messages, and the reading of it.
|
|
3
|
+
*
|
|
4
|
+
* A catalog is `en.json` — the source of truth — with one file per language
|
|
5
|
+
* beside it. English is part of the page, because it is what every missing
|
|
6
|
+
* message falls back to; the others are fetched when a visitor asks for them,
|
|
7
|
+
* so a site nobody reads in German never downloads the German.
|
|
8
|
+
*
|
|
9
|
+
* Only the plain `{name}` argument of ICU MessageFormat is filled here. A
|
|
10
|
+
* plural or a select needs the formatter itself, which is 40 kB an ordinary
|
|
11
|
+
* visit must not pay for — `check-messages` refuses one in a catalog, and the
|
|
12
|
+
* page is written with a key per branch instead.
|
|
13
|
+
*/
|
|
14
|
+
import { ownMessage } from "../../translate/core/catalog.js";
|
|
15
|
+
import { DEFAULT_LANGUAGE } from "./languages.js";
|
|
16
|
+
import { messageSession, notifyMessages } from "./session.js";
|
|
17
|
+
/**
|
|
18
|
+
* The messages of one repository, read in whichever language the page is
|
|
19
|
+
* written in.
|
|
20
|
+
*/
|
|
21
|
+
export class MessageCatalog {
|
|
22
|
+
/** The name the page knows this catalog by. */
|
|
23
|
+
id;
|
|
24
|
+
/** What a translator's session and the overlay need to place an edit. */
|
|
25
|
+
source;
|
|
26
|
+
#loaded = new Map();
|
|
27
|
+
#loaders = new Map();
|
|
28
|
+
#pending = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* Declare a catalog.
|
|
31
|
+
* @param options - See {@link MessageCatalogOptions}.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options) {
|
|
34
|
+
const { id, repository, directory, source, translations = {} } = options;
|
|
35
|
+
this.id = id;
|
|
36
|
+
this.source = { id, repository, directory, messages: source };
|
|
37
|
+
this.#loaded.set(DEFAULT_LANGUAGE, source);
|
|
38
|
+
for (const [language, messages] of Object.entries(translations)) {
|
|
39
|
+
if (messages === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
if (typeof messages === 'function') {
|
|
42
|
+
this.#loaders.set(language, messages);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.#loaded.set(language, messages);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The languages this catalog carries, whether or not they are in memory.
|
|
51
|
+
* @returns The languages, English first.
|
|
52
|
+
*/
|
|
53
|
+
get languages() {
|
|
54
|
+
return [...new Set([...this.#loaded.keys(), ...this.#loaders.keys()])];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The text a key carries in one language.
|
|
58
|
+
* @param key - Key to read.
|
|
59
|
+
* @param language - Language to read it in.
|
|
60
|
+
* @param options - See {@link TranslateOptions}.
|
|
61
|
+
* @returns The text.
|
|
62
|
+
*/
|
|
63
|
+
translate(key, language, options = {}) {
|
|
64
|
+
const { fallback = key, values } = options;
|
|
65
|
+
const english = this.source.messages;
|
|
66
|
+
const session = messageSession();
|
|
67
|
+
if (session !== null) {
|
|
68
|
+
// A key the catalog does not declare is not the translator's to edit:
|
|
69
|
+
// marking it would offer them a message that lives nowhere.
|
|
70
|
+
if (ownMessage(english, key) === undefined)
|
|
71
|
+
return fill(fallback, values);
|
|
72
|
+
return session.format(this.id, key, values);
|
|
73
|
+
}
|
|
74
|
+
const translated = this.#loaded.get(language);
|
|
75
|
+
const message = (translated === undefined ? undefined : ownMessage(translated, key)) ??
|
|
76
|
+
ownMessage(english, key) ??
|
|
77
|
+
fallback;
|
|
78
|
+
return fill(message, values);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The messages of a language, once they are in memory.
|
|
82
|
+
* @param language - Language asked for.
|
|
83
|
+
* @returns The messages, or an empty catalog while they are still coming.
|
|
84
|
+
*/
|
|
85
|
+
messages(language) {
|
|
86
|
+
return this.#loaded.get(language) ?? {};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetch a language's messages, if they are not in memory already.
|
|
90
|
+
* @param language - Language to read next.
|
|
91
|
+
* @returns Its messages.
|
|
92
|
+
*/
|
|
93
|
+
async load(language) {
|
|
94
|
+
const loaded = this.#loaded.get(language);
|
|
95
|
+
if (loaded !== undefined)
|
|
96
|
+
return loaded;
|
|
97
|
+
const pending = this.#pending.get(language);
|
|
98
|
+
if (pending !== undefined)
|
|
99
|
+
return pending;
|
|
100
|
+
const loader = this.#loaders.get(language);
|
|
101
|
+
if (loader === undefined)
|
|
102
|
+
return {};
|
|
103
|
+
const fetching = loader().then((module) => {
|
|
104
|
+
this.#loaded.set(language, module.default);
|
|
105
|
+
this.#pending.delete(language);
|
|
106
|
+
notifyMessages();
|
|
107
|
+
return module.default;
|
|
108
|
+
}, () => {
|
|
109
|
+
// A language that cannot be fetched is a page in English, never a
|
|
110
|
+
// page of raw keys: forget the attempt so a later render retries.
|
|
111
|
+
this.#pending.delete(language);
|
|
112
|
+
return {};
|
|
113
|
+
});
|
|
114
|
+
this.#pending.set(language, fetching);
|
|
115
|
+
return fetching;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Start fetching a language without waiting for it. Safe to call on every
|
|
119
|
+
* render: a language already in memory, or already on its way, costs
|
|
120
|
+
* nothing.
|
|
121
|
+
* @param language - Language the page is about to be written in.
|
|
122
|
+
*/
|
|
123
|
+
prefetch(language) {
|
|
124
|
+
if (this.#loaded.has(language) || this.#pending.has(language))
|
|
125
|
+
return;
|
|
126
|
+
void this.load(language);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const PLACEHOLDER = /\{(?<name>\w+)\}/g;
|
|
130
|
+
function fill(message, values) {
|
|
131
|
+
if (values === undefined)
|
|
132
|
+
return message;
|
|
133
|
+
return message.replaceAll(PLACEHOLDER, (match, name) => Object.hasOwn(values, name) ? String(values[name]) : match);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=messageCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageCatalog.js","sourceRoot":"","sources":["../../../src/i18n/core/messageCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqD9D;;;GAGG;AACH,MAAM,O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AAE,CAC7D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageValues.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/messageValues.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageValues.js","sourceRoot":"","sources":["../../../src/i18n/core/messageValues.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the page formats its messages from, and who is told when that changes.
|
|
3
|
+
*
|
|
4
|
+
* Ordinarily a message is read straight out of a catalog. While a translator
|
|
5
|
+
* has the page open, every message goes through their session instead — marked
|
|
6
|
+
* invisibly so the overlay can find it in the DOM, and answered with whatever
|
|
7
|
+
* they have typed rather than with what was published. Both the session and a
|
|
8
|
+
* language arriving late are changes the page has to redraw for, so they share
|
|
9
|
+
* one version counter and one set of listeners.
|
|
10
|
+
*/
|
|
11
|
+
import type { MessageValues } from './messageValues.ts';
|
|
12
|
+
/**
|
|
13
|
+
* What a page in translate mode formats through — satisfied by
|
|
14
|
+
* `TranslateSession` from `react-cheminfo/translate`, which is never imported
|
|
15
|
+
* here: an ordinary visit must not load the ICU formatter behind it.
|
|
16
|
+
*/
|
|
17
|
+
export interface MessageSession {
|
|
18
|
+
/** The message of a catalog, formatted and marked. */
|
|
19
|
+
format: (catalogId: string, key: string, values?: MessageValues) => string;
|
|
20
|
+
/** Be told whenever an edit is typed; returns the function that stops it. */
|
|
21
|
+
subscribe?: (listener: () => void) => () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Format every message through a translator's session from now on.
|
|
25
|
+
*
|
|
26
|
+
* While one is set it is the session's locale the page is written in, not the
|
|
27
|
+
* visitor's preference, and every message carries the marker the overlay finds
|
|
28
|
+
* it by.
|
|
29
|
+
* @param active - The session, or `null` to go back to the catalogs.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setMessageSession(active: MessageSession | null): void;
|
|
32
|
+
/**
|
|
33
|
+
* The session the page formats through, if a translator has it open.
|
|
34
|
+
* @returns The session, or `null`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function messageSession(): MessageSession | null;
|
|
37
|
+
/**
|
|
38
|
+
* How many times the text of the page has changed — a session set or dropped,
|
|
39
|
+
* an edit typed, a language finished loading.
|
|
40
|
+
* @returns The count, which only ever grows.
|
|
41
|
+
*/
|
|
42
|
+
export declare function messagesVersion(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Be told whenever the text of the page changes.
|
|
45
|
+
* @param listener - Called after each change.
|
|
46
|
+
* @returns The function that stops it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function subscribeToMessages(listener: () => void): () => void;
|
|
49
|
+
/** Say that the text of the page has changed. Never part of the public API. */
|
|
50
|
+
export declare function notifyMessages(): void;
|
|
51
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC3E,6EAA6E;IAC7E,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAClD;AAOD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAQrE;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,cAAc,GAAG,IAAI,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKpE;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,IAAI,IAAI,CAGrC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the page formats its messages from, and who is told when that changes.
|
|
3
|
+
*
|
|
4
|
+
* Ordinarily a message is read straight out of a catalog. While a translator
|
|
5
|
+
* has the page open, every message goes through their session instead — marked
|
|
6
|
+
* invisibly so the overlay can find it in the DOM, and answered with whatever
|
|
7
|
+
* they have typed rather than with what was published. Both the session and a
|
|
8
|
+
* language arriving late are changes the page has to redraw for, so they share
|
|
9
|
+
* one version counter and one set of listeners.
|
|
10
|
+
*/
|
|
11
|
+
let session = null;
|
|
12
|
+
let stopListening = null;
|
|
13
|
+
let version = 0;
|
|
14
|
+
const listeners = new Set();
|
|
15
|
+
/**
|
|
16
|
+
* Format every message through a translator's session from now on.
|
|
17
|
+
*
|
|
18
|
+
* While one is set it is the session's locale the page is written in, not the
|
|
19
|
+
* visitor's preference, and every message carries the marker the overlay finds
|
|
20
|
+
* it by.
|
|
21
|
+
* @param active - The session, or `null` to go back to the catalogs.
|
|
22
|
+
*/
|
|
23
|
+
export function setMessageSession(active) {
|
|
24
|
+
stopListening?.();
|
|
25
|
+
stopListening = null;
|
|
26
|
+
session = active;
|
|
27
|
+
if (active?.subscribe !== undefined) {
|
|
28
|
+
stopListening = active.subscribe(notifyMessages);
|
|
29
|
+
}
|
|
30
|
+
notifyMessages();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The session the page formats through, if a translator has it open.
|
|
34
|
+
* @returns The session, or `null`.
|
|
35
|
+
*/
|
|
36
|
+
export function messageSession() {
|
|
37
|
+
return session;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How many times the text of the page has changed — a session set or dropped,
|
|
41
|
+
* an edit typed, a language finished loading.
|
|
42
|
+
* @returns The count, which only ever grows.
|
|
43
|
+
*/
|
|
44
|
+
export function messagesVersion() {
|
|
45
|
+
return version;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Be told whenever the text of the page changes.
|
|
49
|
+
* @param listener - Called after each change.
|
|
50
|
+
* @returns The function that stops it.
|
|
51
|
+
*/
|
|
52
|
+
export function subscribeToMessages(listener) {
|
|
53
|
+
listeners.add(listener);
|
|
54
|
+
return () => {
|
|
55
|
+
listeners.delete(listener);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Say that the text of the page has changed. Never part of the public API. */
|
|
59
|
+
export function notifyMessages() {
|
|
60
|
+
version++;
|
|
61
|
+
for (const listener of listeners)
|
|
62
|
+
listener();
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/i18n/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,IAAI,OAAO,GAA0B,IAAI,CAAC;AAC1C,IAAI,aAAa,GAAwB,IAAI,CAAC;AAC9C,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA6B;IAC7D,aAAa,EAAE,EAAE,CAAC;IAClB,aAAa,GAAG,IAAI,CAAC;IACrB,OAAO,GAAG,MAAM,CAAC;IACjB,IAAI,MAAM,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;QACpC,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,CAAC;IACD,cAAc,EAAE,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAoB;IACtD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,CAAC;IACV,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handing a page's catalogs to a translator.
|
|
3
|
+
*
|
|
4
|
+
* `startTranslating` wants the catalogs and, beside them, whatever of the
|
|
5
|
+
* target language is already published — that is what tells the overlay which
|
|
6
|
+
* messages are still missing. The published messages of a language are exactly
|
|
7
|
+
* what a catalog fetches on demand, so they are gathered here rather than
|
|
8
|
+
* re-imported by every site.
|
|
9
|
+
*/
|
|
10
|
+
import type { CatalogSource, Messages } from '../../translate/core/catalog.ts';
|
|
11
|
+
import type { MessageCatalog } from './messageCatalog.ts';
|
|
12
|
+
/** What `startTranslating` is handed. */
|
|
13
|
+
export interface LoadedCatalogs {
|
|
14
|
+
/** The catalogs, as the session registers them. */
|
|
15
|
+
catalogs: CatalogSource[];
|
|
16
|
+
/** What is already published in the locale, by catalog id. */
|
|
17
|
+
translations: Record<string, Messages>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetch what each catalog already publishes in a locale.
|
|
21
|
+
* @param catalogs - The catalogs the page renders from.
|
|
22
|
+
* @param locale - The locale being translated into, which may well be one the
|
|
23
|
+
* family does not speak yet — then nothing is published and every message is
|
|
24
|
+
* offered as missing.
|
|
25
|
+
* @returns See {@link LoadedCatalogs}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadCatalogs(catalogs: ReadonlyArray<MessageCatalog<string>>, locale: string): Promise<LoadedCatalogs>;
|
|
28
|
+
//# sourceMappingURL=translateSetup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translateSetup.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/translateSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAC/C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAYzB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handing a page's catalogs to a translator.
|
|
3
|
+
*
|
|
4
|
+
* `startTranslating` wants the catalogs and, beside them, whatever of the
|
|
5
|
+
* target language is already published — that is what tells the overlay which
|
|
6
|
+
* messages are still missing. The published messages of a language are exactly
|
|
7
|
+
* what a catalog fetches on demand, so they are gathered here rather than
|
|
8
|
+
* re-imported by every site.
|
|
9
|
+
*/
|
|
10
|
+
import { isLanguage } from "./languages.js";
|
|
11
|
+
/**
|
|
12
|
+
* Fetch what each catalog already publishes in a locale.
|
|
13
|
+
* @param catalogs - The catalogs the page renders from.
|
|
14
|
+
* @param locale - The locale being translated into, which may well be one the
|
|
15
|
+
* family does not speak yet — then nothing is published and every message is
|
|
16
|
+
* offered as missing.
|
|
17
|
+
* @returns See {@link LoadedCatalogs}.
|
|
18
|
+
*/
|
|
19
|
+
export async function loadCatalogs(catalogs, locale) {
|
|
20
|
+
const language = isLanguage(locale) ? locale : undefined;
|
|
21
|
+
const translations = {};
|
|
22
|
+
if (language !== undefined) {
|
|
23
|
+
const loaded = await Promise.all(catalogs.map(async (catalog) => catalog.load(language)));
|
|
24
|
+
for (const [index, catalog] of catalogs.entries()) {
|
|
25
|
+
translations[catalog.id] = loaded[index] ?? {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { catalogs: catalogs.map((catalog) => catalog.source), translations };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=translateSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translateSetup.js","sourceRoot":"","sources":["../../../src/i18n/core/translateSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAW5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAA+C,EAC/C,MAAc;IAEd,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,MAAM,YAAY,GAA6B,EAAE,CAAC;IAClD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CACxD,CAAC;QACF,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Language } from '../core/languages.ts';
|
|
3
|
+
/** Props of {@link LanguageSelect}. */
|
|
4
|
+
export interface LanguageSelectProps {
|
|
5
|
+
/** The language the site is written in. */
|
|
6
|
+
value: Language;
|
|
7
|
+
/** Called with the language picked. */
|
|
8
|
+
onChange: (language: Language) => void;
|
|
9
|
+
/**
|
|
10
|
+
* The languages on offer, for a site that is not written in all four yet.
|
|
11
|
+
* @default LANGUAGES
|
|
12
|
+
*/
|
|
13
|
+
languages?: readonly Language[];
|
|
14
|
+
/**
|
|
15
|
+
* Whether the bar has run out of room, so the row collapses to the language
|
|
16
|
+
* in force and a click advances to the next.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
compact?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* `data-testid` of the row; each button carries it suffixed by its tag.
|
|
22
|
+
* @default 'language-select'
|
|
23
|
+
*/
|
|
24
|
+
testId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The language switch of the site header: the tags themselves, the one in
|
|
28
|
+
* force pressed.
|
|
29
|
+
*
|
|
30
|
+
* A language names itself — `FR` in the bar, `Français` behind it — because a
|
|
31
|
+
* reader looking for their own language would have to know English to find it
|
|
32
|
+
* written any other way.
|
|
33
|
+
* @param props - See {@link LanguageSelectProps}.
|
|
34
|
+
* @returns The row.
|
|
35
|
+
*/
|
|
36
|
+
export declare function LanguageSelect(props: LanguageSelectProps): ReactElement;
|
|
37
|
+
//# sourceMappingURL=LanguageSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/LanguageSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKrD,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAC;IAChB,uCAAuC;IACvC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAoBvE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HeaderToggle } from "../../chrome/ui/HeaderToggle.js";
|
|
3
|
+
import { LANGUAGES, LANGUAGE_LABELS } from "../core/languages.js";
|
|
4
|
+
import { useChromeT } from "./useT.js";
|
|
5
|
+
/**
|
|
6
|
+
* The language switch of the site header: the tags themselves, the one in
|
|
7
|
+
* force pressed.
|
|
8
|
+
*
|
|
9
|
+
* A language names itself — `FR` in the bar, `Français` behind it — because a
|
|
10
|
+
* reader looking for their own language would have to know English to find it
|
|
11
|
+
* written any other way.
|
|
12
|
+
* @param props - See {@link LanguageSelectProps}.
|
|
13
|
+
* @returns The row.
|
|
14
|
+
*/
|
|
15
|
+
export function LanguageSelect(props) {
|
|
16
|
+
const { value, onChange, languages = LANGUAGES, compact = false, testId = 'language-select', } = props;
|
|
17
|
+
const t = useChromeT();
|
|
18
|
+
return (_jsx(HeaderToggle, { label: t('language.label'), options: languages.map(toOption), value: value, onChange: onChange, compact: compact, testId: testId }));
|
|
19
|
+
}
|
|
20
|
+
function toOption(language) {
|
|
21
|
+
return {
|
|
22
|
+
value: language,
|
|
23
|
+
label: language.toUpperCase(),
|
|
24
|
+
title: LANGUAGE_LABELS[language],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=LanguageSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LanguageSelect.js","sourceRoot":"","sources":["../../../src/i18n/ui/LanguageSelect.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAkC,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA0BvC;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,SAAS,EACrB,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,iBAAiB,GAC3B,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IAEvB,OAAO,CACL,KAAC,YAAY,IACX,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAC1B,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAChC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,QAAkB;IAClC,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE;QAC7B,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { LanguageSelectProps } from './LanguageSelect.tsx';
|
|
2
|
+
export { LanguageSelect } from './LanguageSelect.tsx';
|
|
3
|
+
export { useIsTranslating, useLanguage, useMessagesVersion, } from './useLanguage.ts';
|
|
4
|
+
export type { Translate } from './useT.ts';
|
|
5
|
+
export { translateMessage, useChromeT, useT } from './useT.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/i18n/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Language } from '../core/languages.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The language the page is written in.
|
|
4
|
+
*
|
|
5
|
+
* It is what the site declared with `SiteLanguage`, or what the address names
|
|
6
|
+
* when the site declared nothing — the same value every link out of the page
|
|
7
|
+
* carries, so the chrome is never written in a language the links deny.
|
|
8
|
+
* @returns The language.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useLanguage(): Language;
|
|
11
|
+
/**
|
|
12
|
+
* Redraw whenever the text of the page changes — a language finished loading,
|
|
13
|
+
* a translator typed an edit, a session was set or dropped.
|
|
14
|
+
* @returns The version the page was drawn at.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useMessagesVersion(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a translator has the page open, in which case the language switch
|
|
19
|
+
* says nothing about what is on show.
|
|
20
|
+
* @returns True in translate mode.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useIsTranslating(): boolean;
|
|
23
|
+
//# sourceMappingURL=useLanguage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/useLanguage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAKtC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAG1C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { useSiteLanguage } from "../../language/ui/siteLanguageContext.js";
|
|
3
|
+
import { DEFAULT_LANGUAGE, isLanguage } from "../core/languages.js";
|
|
4
|
+
import { messageSession, messagesVersion, subscribeToMessages, } from "../core/session.js";
|
|
5
|
+
/**
|
|
6
|
+
* The language the page is written in.
|
|
7
|
+
*
|
|
8
|
+
* It is what the site declared with `SiteLanguage`, or what the address names
|
|
9
|
+
* when the site declared nothing — the same value every link out of the page
|
|
10
|
+
* carries, so the chrome is never written in a language the links deny.
|
|
11
|
+
* @returns The language.
|
|
12
|
+
*/
|
|
13
|
+
export function useLanguage() {
|
|
14
|
+
const declared = useSiteLanguage();
|
|
15
|
+
return declared !== undefined && isLanguage(declared)
|
|
16
|
+
? declared
|
|
17
|
+
: DEFAULT_LANGUAGE;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Redraw whenever the text of the page changes — a language finished loading,
|
|
21
|
+
* a translator typed an edit, a session was set or dropped.
|
|
22
|
+
* @returns The version the page was drawn at.
|
|
23
|
+
*/
|
|
24
|
+
export function useMessagesVersion() {
|
|
25
|
+
return useSyncExternalStore(subscribeToMessages, messagesVersion, messagesVersion);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a translator has the page open, in which case the language switch
|
|
29
|
+
* says nothing about what is on show.
|
|
30
|
+
* @returns True in translate mode.
|
|
31
|
+
*/
|
|
32
|
+
export function useIsTranslating() {
|
|
33
|
+
useMessagesVersion();
|
|
34
|
+
return messageSession() !== null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useLanguage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLanguage.js","sourceRoot":"","sources":["../../../src/i18n/ui/useLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,QAAQ,KAAK,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC;QACnD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,gBAAgB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,oBAAoB,CACzB,mBAAmB,EACnB,eAAe,EACf,eAAe,CAChB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,kBAAkB,EAAE,CAAC;IACrB,OAAO,cAAc,EAAE,KAAK,IAAI,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ChromeKey } from '../core/chromeCatalog.ts';
|
|
2
|
+
import type { Language, LooseKey, MessageValues, TranslateOptions } from '../core/index.ts';
|
|
3
|
+
import type { MessageCatalog } from '../core/messageCatalog.ts';
|
|
4
|
+
/**
|
|
5
|
+
* What a component reads its text with.
|
|
6
|
+
*
|
|
7
|
+
* `t(key)` is a key the catalog declares, checked at compile time.
|
|
8
|
+
* `t.or(key, fallback)` is a key built from the data — a site's id, an
|
|
9
|
+
* element's symbol — which the catalog may not have caught up with yet; it
|
|
10
|
+
* reads as the fallback rather than as a raw key.
|
|
11
|
+
*/
|
|
12
|
+
export type Translate<TKey extends string> = ((key: LooseKey<TKey>, values?: MessageValues) => string) & {
|
|
13
|
+
or: (key: string, fallback: string, values?: MessageValues) => string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The formatter of a catalog's text, in the language the page is written in.
|
|
17
|
+
*
|
|
18
|
+
* It is meant to be called while rendering, never kept in a module constant:
|
|
19
|
+
* the language and a translator's edits both change under the page, and only a
|
|
20
|
+
* render picks them up.
|
|
21
|
+
* @param catalog - The catalog to read, typed by its English keys.
|
|
22
|
+
* @returns See {@link Translate}.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useT<TKey extends string>(catalog: MessageCatalog<TKey>): Translate<TKey>;
|
|
25
|
+
/**
|
|
26
|
+
* The formatter of this library's own text — the header, the Tools menu, the
|
|
27
|
+
* share dialog, the About page.
|
|
28
|
+
*
|
|
29
|
+
* A site reads it for a word it shows beside the chrome's own, so `Share` and
|
|
30
|
+
* `Cite` are written the same way everywhere.
|
|
31
|
+
* @returns `t(key, values)`, typed by the chrome's English catalog.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useChromeT(): Translate<ChromeKey>;
|
|
34
|
+
/**
|
|
35
|
+
* One message of a catalog, outside a component.
|
|
36
|
+
*
|
|
37
|
+
* Only for the rare place a hook cannot go — a label computed in a module
|
|
38
|
+
* helper, a message thrown from a worker. A component uses {@link useT}, which
|
|
39
|
+
* redraws when the language does.
|
|
40
|
+
* @param catalog - The catalog to read.
|
|
41
|
+
* @param key - Key to read.
|
|
42
|
+
* @param language - Language to read it in.
|
|
43
|
+
* @param options - See `TranslateOptions`.
|
|
44
|
+
* @returns The text.
|
|
45
|
+
*/
|
|
46
|
+
export declare function translateMessage<TKey extends string>(catalog: MessageCatalog<TKey>, key: LooseKey<TKey>, language: Language, options?: TranslateOptions): string;
|
|
47
|
+
//# sourceMappingURL=useT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useT.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/useT.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,SAAS,MAAM,IAAI,CAAC,CAC5C,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,EACnB,MAAM,CAAC,EAAE,aAAa,KACnB,MAAM,CAAC,GAAG;IACb,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,IAAI,SAAS,MAAM,EACtC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAC5B,SAAS,CAAC,IAAI,CAAC,CAKjB;AAeD;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,SAAS,CAAC,SAAS,CAAC,CAEjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,EAC7B,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CAER"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CHROME_CATALOG } from "../core/chromeCatalog.js";
|
|
2
|
+
import { useLanguage, useMessagesVersion } from "./useLanguage.js";
|
|
3
|
+
/**
|
|
4
|
+
* The formatter of a catalog's text, in the language the page is written in.
|
|
5
|
+
*
|
|
6
|
+
* It is meant to be called while rendering, never kept in a module constant:
|
|
7
|
+
* the language and a translator's edits both change under the page, and only a
|
|
8
|
+
* render picks them up.
|
|
9
|
+
* @param catalog - The catalog to read, typed by its English keys.
|
|
10
|
+
* @returns See {@link Translate}.
|
|
11
|
+
*/
|
|
12
|
+
export function useT(catalog) {
|
|
13
|
+
const language = useLanguage();
|
|
14
|
+
useMessagesVersion();
|
|
15
|
+
catalog.prefetch(language);
|
|
16
|
+
return translator(catalog, language);
|
|
17
|
+
}
|
|
18
|
+
// Built outside the hook, because the `or` form is a property of the function
|
|
19
|
+
// itself and a render may not write to a value it has just read.
|
|
20
|
+
function translator(catalog, language) {
|
|
21
|
+
const translate = (key, values) => catalog.translate(key, language, { values });
|
|
22
|
+
translate.or = (key, fallback, values) => catalog.translate(key, language, { fallback, values });
|
|
23
|
+
return translate;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The formatter of this library's own text — the header, the Tools menu, the
|
|
27
|
+
* share dialog, the About page.
|
|
28
|
+
*
|
|
29
|
+
* A site reads it for a word it shows beside the chrome's own, so `Share` and
|
|
30
|
+
* `Cite` are written the same way everywhere.
|
|
31
|
+
* @returns `t(key, values)`, typed by the chrome's English catalog.
|
|
32
|
+
*/
|
|
33
|
+
export function useChromeT() {
|
|
34
|
+
return useT(CHROME_CATALOG);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One message of a catalog, outside a component.
|
|
38
|
+
*
|
|
39
|
+
* Only for the rare place a hook cannot go — a label computed in a module
|
|
40
|
+
* helper, a message thrown from a worker. A component uses {@link useT}, which
|
|
41
|
+
* redraws when the language does.
|
|
42
|
+
* @param catalog - The catalog to read.
|
|
43
|
+
* @param key - Key to read.
|
|
44
|
+
* @param language - Language to read it in.
|
|
45
|
+
* @param options - See `TranslateOptions`.
|
|
46
|
+
* @returns The text.
|
|
47
|
+
*/
|
|
48
|
+
export function translateMessage(catalog, key, language, options) {
|
|
49
|
+
return catalog.translate(key, language, options);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=useT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useT.js","sourceRoot":"","sources":["../../../src/i18n/ui/useT.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBnE;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAClB,OAA6B;IAE7B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3B,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,8EAA8E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