react-cheminfo 0.32.0 → 0.33.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.
Files changed (55) hide show
  1. package/lib/i18n/core/chromeCatalog.d.ts +2 -2
  2. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  3. package/lib/i18n/core/chromeCatalog.js +10 -4
  4. package/lib/i18n/core/chromeCatalog.js.map +1 -1
  5. package/lib/i18n/core/index.d.ts +2 -0
  6. package/lib/i18n/core/index.d.ts.map +1 -1
  7. package/lib/i18n/core/index.js +1 -0
  8. package/lib/i18n/core/index.js.map +1 -1
  9. package/lib/i18n/core/languages.d.ts +4 -4
  10. package/lib/i18n/core/languages.d.ts.map +1 -1
  11. package/lib/i18n/core/languages.js +5 -4
  12. package/lib/i18n/core/languages.js.map +1 -1
  13. package/lib/i18n/core/prose.d.ts +32 -0
  14. package/lib/i18n/core/prose.d.ts.map +1 -0
  15. package/lib/i18n/core/prose.js +45 -0
  16. package/lib/i18n/core/prose.js.map +1 -0
  17. package/lib/i18n/ui/Prose.d.ts +28 -0
  18. package/lib/i18n/ui/Prose.d.ts.map +1 -0
  19. package/lib/i18n/ui/Prose.js +14 -0
  20. package/lib/i18n/ui/Prose.js.map +1 -0
  21. package/lib/i18n/ui/index.d.ts +2 -0
  22. package/lib/i18n/ui/index.d.ts.map +1 -1
  23. package/lib/i18n/ui/index.js +1 -0
  24. package/lib/i18n/ui/index.js.map +1 -1
  25. package/lib/locales/de.json +4 -0
  26. package/lib/locales/en.json +4 -0
  27. package/lib/locales/es.json +4 -0
  28. package/lib/locales/fr.json +4 -0
  29. package/lib/locales/it.json +459 -0
  30. package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts +12 -2
  31. package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts.map +1 -1
  32. package/lib/orbital/ui/AtomicOrbitalCanvas.js +17 -3
  33. package/lib/orbital/ui/AtomicOrbitalCanvas.js.map +1 -1
  34. package/lib/orbital/ui/AtomicOrbitalControls.d.ts +10 -5
  35. package/lib/orbital/ui/AtomicOrbitalControls.d.ts.map +1 -1
  36. package/lib/orbital/ui/AtomicOrbitalControls.js +12 -7
  37. package/lib/orbital/ui/AtomicOrbitalControls.js.map +1 -1
  38. package/lib/orbital/ui/AtomicOrbitalViewer.d.ts +8 -1
  39. package/lib/orbital/ui/AtomicOrbitalViewer.d.ts.map +1 -1
  40. package/lib/orbital/ui/AtomicOrbitalViewer.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/i18n/core/chromeCatalog.ts +10 -4
  43. package/src/i18n/core/index.ts +2 -0
  44. package/src/i18n/core/languages.ts +5 -4
  45. package/src/i18n/core/prose.ts +53 -0
  46. package/src/i18n/ui/Prose.tsx +47 -0
  47. package/src/i18n/ui/index.ts +2 -0
  48. package/src/locales/de.json +4 -0
  49. package/src/locales/en.json +4 -0
  50. package/src/locales/es.json +4 -0
  51. package/src/locales/fr.json +4 -0
  52. package/src/locales/it.json +459 -0
  53. package/src/orbital/ui/AtomicOrbitalCanvas.tsx +32 -5
  54. package/src/orbital/ui/AtomicOrbitalControls.tsx +26 -6
  55. package/src/orbital/ui/AtomicOrbitalViewer.tsx +8 -1
@@ -1,30 +1,35 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * The two controls an orbital canvas owns: the cartesian frame, and the way
4
- * back to the framing the orbital opened on — a change of orbital keeps
5
- * whatever angle and zoom the student is on.
3
+ * The three controls an orbital canvas owns: the cartesian frame, the slow
4
+ * spin that makes a 3D shape readable on a flat screen, and the way back to the
5
+ * framing the orbital opened on — a change of orbital keeps whatever angle and
6
+ * zoom the student is on.
6
7
  */
7
8
  import { Button } from '@blueprintjs/core';
8
9
  import { HelpTooltip } from "../../help/ui/HelpTooltip.js";
9
10
  import { useChromeT } from "../../i18n/ui/useT.js";
10
11
  /**
11
- * The frame and reset buttons, in the canvas's top-right corner.
12
+ * The frame, spin and reset buttons, in the canvas's top-right corner.
12
13
  * @param props - See {@link AtomicOrbitalControlsProps}.
13
- * @returns The two buttons.
14
+ * @returns The three buttons.
14
15
  */
15
16
  export function AtomicOrbitalControls(props) {
16
- const { axes, onToggleAxes, onResetView } = props;
17
+ const { axes, onToggleAxes, spinning, onToggleSpin, onResetView } = props;
17
18
  const t = useChromeT();
18
19
  const axesHelp = {
19
20
  title: t('orbital.axesTitle'),
20
21
  body: t('orbital.axesBody'),
21
22
  example: { code: '3d_yz', note: t('orbital.axesExample') },
22
23
  };
24
+ const spinHelp = {
25
+ title: t('orbital.spinTitle'),
26
+ body: t('orbital.spinBody'),
27
+ };
23
28
  const resetHelp = {
24
29
  title: t('orbital.resetTitle'),
25
30
  body: t('orbital.resetBody'),
26
31
  };
27
- return (_jsxs("div", { style: CONTROLS_STYLE, children: [_jsx(HelpTooltip, { content: axesHelp, placement: "bottom", children: _jsx(Button, { variant: "minimal", size: "small", icon: "grid", active: axes, "aria-label": t('orbital.showAxes'), "aria-pressed": axes, onClick: onToggleAxes }) }), _jsx(HelpTooltip, { content: resetHelp, placement: "bottom", children: _jsx(Button, { variant: "minimal", size: "small", icon: "zoom-to-fit", "aria-label": t('orbital.resetTitle'), onClick: onResetView }) })] }));
32
+ return (_jsxs("div", { style: CONTROLS_STYLE, children: [_jsx(HelpTooltip, { content: axesHelp, placement: "bottom", children: _jsx(Button, { variant: "minimal", size: "small", icon: "grid", active: axes, "aria-label": t('orbital.showAxes'), "aria-pressed": axes, onClick: onToggleAxes }) }), _jsx(HelpTooltip, { content: spinHelp, placement: "bottom", children: _jsx(Button, { variant: "minimal", size: "small", icon: "refresh", active: spinning, "aria-label": t('orbital.spin'), "aria-pressed": spinning, onClick: onToggleSpin }) }), _jsx(HelpTooltip, { content: resetHelp, placement: "bottom", children: _jsx(Button, { variant: "minimal", size: "small", icon: "zoom-to-fit", "aria-label": t('orbital.resetTitle'), onClick: onResetView }) })] }));
28
33
  }
29
34
  const CONTROLS_STYLE = {
30
35
  position: 'absol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AmB,CAAC;KAC7B,CAAC;IACF,OAAO,CACL,eAAK,KAAK,EAAE,cAAc,aACxB,KAAC,WAAW,IAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,QAAQ,YAChD,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,IAAI,gBACA,CAAC,CAAC,kBAAkB,CAAC,kBACnB,IAAI,EAClB,OAAO,EAAE,YAAY,GACrB,GACU,EACd,KAAC,WAAW,IAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,QAAQ,YAChD,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,QAAQ,gBACJ,CAAC,CAAC,cAAc,CAAC,kBACf,QAAQ,EACtB,OAAO,EAAE,YAAY,GACrB,GACU,EACd,KAAC,WAAW,IAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAC,QAAQ,YACjD,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,aAAa,gBACN,CAAC,CAAC,oBAAoB,CAAC,EACnC,OAAO,EAAE,WAAW,GACpB,GACU,IACV,CACP,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAkB;IACpC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,CAAC;CACP,CAAC"}
@@ -52,10 +52,17 @@ export interface AtomicOrbitalViewerProps {
52
52
  */
53
53
  onAxesChange?: (axes: boolean) => void;
54
54
  /**
55
- * Whether the scene turns on its own.
55
+ * Whether the scene turns on its own when the canvas opens. The button in the
56
+ * canvas's corner flips it from there.
56
57
  * @default false
57
58
  */
58
59
  spinning?: boolean;
60
+ /**
61
+ * Called when the student flips the spin, with its new state — so a site can
62
+ * persist the choice and pass it back as `spinning`.
63
+ * @default undefined
64
+ */
65
+ onSpinningChange?: (spinning: boolean) => void;
59
66
  /**
60
67
  * How fast it turns, in molstar's own spin unit. Lower is slower.
61
68
  * @default 0.3
@@ -1 +1 @@
1
- {"version":3,"file":"AtomicOrbitalViewer.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/AtomicOrbitalViewer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAQxD,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,C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,SAAS,EAAE,SAAS,YACnD,iBAAiB,EAAE,CAAC,UAAU,CAAC;gBAC9B,CAAC,CAAC,EAAE,CAAC,qBAAqB,UAAU,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,GAC5D,CACX,CAAC;IACJ,CAAC;IAED,OAAO,CACL,eAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,aAC1C,KAAC,QAAQ,IACP,QAAQ,EACN,cAAK,KAAK,EAAE,UAAU,YACnB,QAAQ,IAAI,CAAC,CAAC,0BAA0B,CAAC,GACtC,YAGR,KAAC,mBAAmB,OAAK,MAAM,EAAE,eAAe,EAAE,UAAU,GAAI,GACvD,EACV,OAAO,KAAK,IAAI,IAAI,CACnB,KAAC,OAAO,IAAC,MAAM,EAAC,QAAQ,EAAC,OAAO,QAAC,KAAK,EAAE,CAAC,CAAC,sBAAsB,CAAC,YAC9D,OAAO,GACA,CACX,IACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,UAAU,GAAkB;IAChC,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,EAAE;IACX,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,KAAK,CAAC,aAAa;IAC/B,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,QAAQ;CACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
@@ -19,7 +19,7 @@ export type ChromeKey = keyof typeof en;
19
19
 
20
20
  /**
21
21
  * The chrome's messages. English is part of the page because it is what a
22
- * missing message falls back to; the other three arrive as a chunk of their
22
+ * missing message falls back to; every other language arrives as a chunk of its
23
23
  * own, so a site read only in English downloads none of them.
24
24
  */
25
25
  export const CHROME_CATALOG = new MessageCatalog<ChromeKey>({
@@ -27,9 +27,15 @@ export const CHROME_CATALOG = new MessageCatalog<ChromeKey>({
27
27
  repository: 'cheminfo/react-cheminfo',
28
28
  directory: 'src/locales',
29
29
  source: en,
30
+ // No `with { type: 'json' }` on these: Vite turns a JSON file into a real
31
+ // JavaScript module, and the attribute makes the browser refuse the chunk it
32
+ // serves for being `text/javascript` — the chrome then stays in English with
33
+ // nothing failing at build or type-check time. The English import above is
34
+ // static, so the bundler resolves it before a browser ever sees it.
30
35
  translations: {
31
- fr: () => import('../../locales/fr.json', { with: { type: 'json' } }),
32
- de: () => import('../../locales/de.json', { with: { type: 'json' } }),
33
- es: () => import('../../locales/es.json', { with: { type: 'json' } }),
36
+ fr: () => import('../../locales/fr.json'),
37
+ de: () => import('../../locales/de.json'),
38
+ es: () => import('../../locales/es.json'),
39
+ it: () => import('../../locales/it.json'),
34
40
  },
35
41
  });
@@ -15,6 +15,8 @@ export type {
15
15
  } from './messageCatalog.ts';
16
16
  export { MessageCatalog } from './messageCatalog.ts';
17
17
  export type { MessageValues } from './messageValues.ts';
18
+ export type { ProsePiece } from './prose.ts';
19
+ export { splitProse } from './prose.ts';
18
20
  export type { MessageSession } from './session.ts';
19
21
  export {
20
22
  messageSession,
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * The languages the family speaks.
3
3
  *
4
- * Four, decided together rather than site by site: a visitor who switches to
5
- * German on one tool and follows a link to the next must land in German there
6
- * too, and a list that differs between two sites makes that impossible.
4
+ * Decided together rather than site by site: a visitor who switches to German
5
+ * on one tool and follows a link to the next must land in German there too, and
6
+ * a list that differs between two sites makes that impossible.
7
7
  */
8
8
 
9
9
  /** Every language a site of the family is written in. */
10
- export const LANGUAGES = ['en', 'fr', 'de', 'es'] as const;
10
+ export const LANGUAGES = ['en', 'fr', 'de', 'es', 'it'] as const;
11
11
 
12
12
  /** One of {@link LANGUAGES}. */
13
13
  export type Language = (typeof LANGUAGES)[number];
@@ -31,6 +31,7 @@ export const LANGUAGE_LABELS: Record<Language, string> = {
31
31
  fr: 'Français',
32
32
  de: 'Deutsch',
33
33
  es: 'Español',
34
+ it: 'Italiano',
34
35
  };
35
36
 
36
37
  /**
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Cutting a paragraph at the placeholders that stand for something drawn.
3
+ *
4
+ * Pure, and its own module: where a link falls in a sentence is the
5
+ * translator's decision — German puts the verb last, French rewrites the
6
+ * possessive around it — so the paragraph is one message with a `{name}` in it
7
+ * rather than fragments glued around a fixed anchor. What the pieces are drawn
8
+ * as is `Prose` in `react-cheminfo/ui`.
9
+ */
10
+
11
+ /** One piece of a paragraph: authored prose, or something the page draws. */
12
+ export type ProsePiece =
13
+ | { kind: 'text'; at: number; text: string }
14
+ | { kind: 'node'; at: number; name: string };
15
+
16
+ const PLACEHOLDER = /\{(?<name>\w+)\}/g;
17
+
18
+ /**
19
+ * Split a paragraph at the placeholders the page has something to draw for.
20
+ *
21
+ * A placeholder nobody named is left inside its text piece: it is either a
22
+ * value the message already had filled in, or a key a translation has got
23
+ * wrong, and neither is worth throwing the paragraph away for.
24
+ * @param text - The message, already written in the language of the page.
25
+ * @param names - The placeholders that stand for something drawn.
26
+ * @returns The pieces, in order, with no empty text piece between two nodes.
27
+ * `at` is the offset in the message, which makes it a stable React key.
28
+ */
29
+ export function splitProse(
30
+ text: string,
31
+ names: readonly string[],
32
+ ): ProsePiece[] {
33
+ const wanted = new Set(names);
34
+ const pieces: ProsePiece[] = [];
35
+ let cursor = 0;
36
+ for (const match of text.matchAll(PLACEHOLDER)) {
37
+ const name = match.groups?.name ?? '';
38
+ if (!wanted.has(name)) continue;
39
+ if (match.index > cursor) {
40
+ pieces.push({
41
+ kind: 'text',
42
+ at: cursor,
43
+ text: text.slice(cursor, match.index),
44
+ });
45
+ }
46
+ pieces.push({ kind: 'node', at: match.index, name });
47
+ cursor = match.index + match[0].length;
48
+ }
49
+ if (cursor < text.length) {
50
+ pieces.push({ kind: 'text', at: cursor, text: text.slice(cursor) });
51
+ }
52
+ return pieces;
53
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A paragraph of authored prose, with its inline marks drawn and its links put
3
+ * back where the sentence wants them.
4
+ *
5
+ * An explanation page is prose, not labels: it carries bold lead-ins, italics
6
+ * and a handful of links into the tool. `**strong**`, `*emphasis*` and
7
+ * `` `code` `` are the inline marks `InlineText` reads. A link is a `{name}`
8
+ * placeholder instead, cut out by `splitProse`, so a translation decides where
9
+ * in the sentence it falls.
10
+ */
11
+
12
+ import type { ReactElement, ReactNode } from 'react';
13
+ import { Fragment } from 'react';
14
+
15
+ import { InlineText } from '../../pedagogy/ui/InlineText.tsx';
16
+ import { splitProse } from '../core/prose.ts';
17
+
18
+ /** Props of {@link Prose}. */
19
+ export interface ProseProps {
20
+ /** The message, already written in the language of the page. */
21
+ text: string;
22
+ /**
23
+ * What each `{name}` placeholder of the message stands for.
24
+ * @default {}
25
+ */
26
+ nodes?: Readonly<Record<string, ReactNode>>;
27
+ }
28
+
29
+ /**
30
+ * Draw one piece of prose.
31
+ * @param props - See {@link ProseProps}.
32
+ * @returns The prose, marks drawn and placeholders replaced.
33
+ */
34
+ export function Prose(props: ProseProps): ReactElement {
35
+ const { text, nodes = {} } = props;
36
+ return (
37
+ <>
38
+ {splitProse(text, Object.keys(nodes)).map((piece) =>
39
+ piece.kind === 'text' ? (
40
+ <InlineText key={piece.at} text={piece.text} />
41
+ ) : (
42
+ <Fragment key={piece.at}>{nodes[piece.name]}</Fragment>
43
+ ),
44
+ )}
45
+ </>
46
+ );
47
+ }
@@ -1,5 +1,7 @@
1
1
  export type { LanguageSelectProps } from './LanguageSelect.tsx';
2
2
  export { LanguageSelect } from './LanguageSelect.tsx';
3
+ export type { ProseProps } from './Prose.tsx';
4
+ export { Prose } from './Prose.tsx';
3
5
  export {
4
6
  useIsTranslating,
5
7
  useLanguage,
@@ -233,6 +233,7 @@
233
233
  "overlay.hoverAName": "Fahren Sie über einen Namen, um zu sehen, was er bewirkt.",
234
234
  "overlay.dismiss": "Schließen",
235
235
  "delimited.copyTable": "Tabelle kopieren",
236
+ "delimited.copyOrDownload": "Daten kopieren oder herunterladen",
236
237
  "delimited.close": "Schließen",
237
238
  "delimited.separator": "Trennzeichen",
238
239
  "delimited.save": "Speichern",
@@ -262,6 +263,9 @@
262
263
  "orbital.axesTitle": "Kartesische Achsen",
263
264
  "orbital.axesBody": "x, y und z durch den Kern zeichnen. Die Bezeichnung benennt ein Orbital danach, wo seine Keulen gegenüber ihnen liegen.",
264
265
  "orbital.axesExample": "vier Keulen zwischen der y- und der z-Achse, keine auf einer von beiden.",
266
+ "orbital.spin": "Das Orbital drehen",
267
+ "orbital.spinTitle": "Drehung",
268
+ "orbital.spinBody": "Das Orbital langsam um seine senkrechte Achse drehen. Ein fester Blickwinkel verbirgt, welche Keulen auf Sie zeigen; ein drehendes Orbital nicht.",
265
269
  "orbital.resetTitle": "Ansicht zurücksetzen",
266
270
  "orbital.resetBody": "Zurück zu Blickwinkel und Zoom, mit denen das Orbital geöffnet wurde. Ein Wechsel des Orbitals behält die Ansicht bei, in die Sie es gedreht haben.",
267
271
  "viewer.capability.noWindow": "Der 3D-Betrachter braucht ein Browserfenster.",
@@ -233,6 +233,7 @@
233
233
  "overlay.hoverAName": "Hover a name for what it does.",
234
234
  "overlay.dismiss": "Dismiss",
235
235
  "delimited.copyTable": "Copy the table",
236
+ "delimited.copyOrDownload": "Copy or download data",
236
237
  "delimited.close": "Close",
237
238
  "delimited.separator": "Separator",
238
239
  "delimited.save": "Save",
@@ -435,6 +436,9 @@
435
436
  "orbital.axesTitle": "Cartesian axes",
436
437
  "orbital.axesBody": "Draw x, y and z through the nucleus. The label names an orbital by where its lobes sit against them.",
437
438
  "orbital.axesExample": "four lobes between the y and z axes, none on either.",
439
+ "orbital.spin": "Spin the orbital",
440
+ "orbital.spinTitle": "Spin",
441
+ "orbital.spinBody": "Turn the orbital slowly on its vertical axis. One fixed angle hides which lobes point towards you; a turning one does not.",
438
442
  "orbital.resetTitle": "Reset the view",
439
443
  "orbital.resetBody": "Back to the angle and zoom the orbital opened on. A change of orbital keeps whatever view you have turned it to.",
440
444
  "viewer.capability.noWindow": "The 3D viewer needs a browser window.",
@@ -233,6 +233,7 @@
233
233
  "overlay.hoverAName": "Pase el puntero sobre un nombre para ver qué hace.",
234
234
  "overlay.dismiss": "Cerrar",
235
235
  "delimited.copyTable": "Copiar la tabla",
236
+ "delimited.copyOrDownload": "Copiar o descargar los datos",
236
237
  "delimited.close": "Cerrar",
237
238
  "delimited.separator": "Separador",
238
239
  "delimited.save": "Guardar",
@@ -262,6 +263,9 @@
262
263
  "orbital.axesTitle": "Ejes cartesianos",
263
264
  "orbital.axesBody": "Trazar x, y y z a través del núcleo. La etiqueta nombra un orbital por dónde quedan sus lóbulos respecto a ellos.",
264
265
  "orbital.axesExample": "cuatro lóbulos entre los ejes y y z, ninguno sobre ninguno de los dos.",
266
+ "orbital.spin": "Girar el orbital",
267
+ "orbital.spinTitle": "Giro",
268
+ "orbital.spinBody": "Girar lentamente el orbital sobre su eje vertical. Un ángulo fijo oculta qué lóbulos apuntan hacia usted; uno que gira, no.",
265
269
  "orbital.resetTitle": "Reiniciar la vista",
266
270
  "orbital.resetBody": "Volver al ángulo y al zoom con los que se abrió el orbital. Un cambio de orbital conserva la vista a la que usted lo haya girado.",
267
271
  "viewer.capability.noWindow": "El visor 3D necesita una ventana de navegador.",
@@ -233,6 +233,7 @@
233
233
  "overlay.hoverAName": "Survolez un nom pour savoir ce qu'il fait.",
234
234
  "overlay.dismiss": "Fermer",
235
235
  "delimited.copyTable": "Copier le tableau",
236
+ "delimited.copyOrDownload": "Copier ou télécharger les données",
236
237
  "delimited.close": "Fermer",
237
238
  "delimited.separator": "Séparateur",
238
239
  "delimited.save": "Enregistrer",
@@ -262,6 +263,9 @@
262
263
  "orbital.axesTitle": "Axes cartésiens",
263
264
  "orbital.axesBody": "Tracer x, y et z à travers le noyau. L'étiquette nomme une orbitale par la position de ses lobes par rapport à eux.",
264
265
  "orbital.axesExample": "quatre lobes entre les axes y et z, aucun sur l'un ou l'autre.",
266
+ "orbital.spin": "Faire tourner l'orbitale",
267
+ "orbital.spinTitle": "Rotation",
268
+ "orbital.spinBody": "Faire tourner lentement l'orbitale sur son axe vertical. Un angle fixe cache quels lobes pointent vers vous ; une orbitale qui tourne, non.",
265
269
  "orbital.resetTitle": "Réinitialiser la vue",
266
270
  "orbital.resetBody": "Revenir à l'angle et au zoom d'ouverture de l'orbitale. Un changement d'orbitale conserve la vue à laquelle vous l'avez tournée.",
267
271
  "viewer.capability.noWindow": "La visionneuse 3D a besoin d'une fenêtre de navigateur.",