Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translatable XML help screens #2456

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
0993c6d
Implement basic HelpDialogMorph
djsrv May 28, 2019
6ddb0d4
Add ScrollFrame to HelpDialogMorph
djsrv May 28, 2019
c361112
Implement basic help screen deserialization
djsrv May 28, 2019
0f28eff
Implement paragraph
djsrv May 28, 2019
af9618c
Use BlockEditorMorph fixLayout in HelpDialogMorph
djsrv May 28, 2019
70a0caa
Fetch XML from help folder
djsrv May 28, 2019
dd7245a
Implement column/row layout
djsrv May 28, 2019
dc4193f
Display scripts in help screens
djsrv May 28, 2019
d5e9636
Improve help screen element positioning
djsrv May 28, 2019
7c08e5b
Allow inline blocks in help screen paragraphs
djsrv May 29, 2019
b4a754b
Adjust help screen elements to fill width
djsrv May 29, 2019
95c85b1
Fix bugs with help screen element widths
djsrv May 29, 2019
8a7799f
Implement basic script diagrams
djsrv May 30, 2019
3a7e2d8
Minor syntax tweaks
djsrv May 30, 2019
7b85e01
Remove unnecessary console.log
djsrv May 30, 2019
9c89e51
Add padding between block and arrow
djsrv May 30, 2019
923dfb4
Fix comment widths
djsrv May 30, 2019
efba913
Implement help screen images
djsrv May 31, 2019
966febb
Temporary hack to fix help screen scrolling
djsrv May 31, 2019
d422fad
Add block thumbnail in top-left of help screen
djsrv May 31, 2019
c35c84e
Call changed() on help screen images after load
djsrv May 31, 2019
2f2ef96
Change help screen padding
djsrv May 31, 2019
fa8ae10
Add forward and bounceOffEdge screens
djsrv May 31, 2019
26be33e
Add bubble help screen
djsrv May 31, 2019
c0f787d
Add more help screens
djsrv Jun 4, 2019
1c55486
Allow gaps in annotation positioning
djsrv Jun 4, 2019
f9f64f3
Make arrows originate from annotation's first line
djsrv Jun 4, 2019
00a235f
Add reverse arrows in diagrams
djsrv Jun 4, 2019
0f89a34
Add custom block support to help screens
djsrv Jun 5, 2019
716352e
Fix help screen annotation positioning
djsrv Jun 5, 2019
a58e598
Add help screens
djsrv Jun 5, 2019
2979664
Add menu support to help screens
djsrv Jun 5, 2019
a94b620
Add more help screens
djsrv Jun 6, 2019
4363a1a
Add script diagram highlights and improved arrows
djsrv Jun 10, 2019
c31d4cb
Add result bubbles to script diagrams
djsrv Jun 10, 2019
a8b5218
Allow images in result bubbles
djsrv Jun 13, 2019
ef63cf6
Allow morph position to be specified manually
djsrv Jun 13, 2019
737f30d
Fixes to help screen layout
djsrv Jun 13, 2019
80569b4
Colored text in help screens
djsrv Jun 13, 2019
7e7d535
Allow Booleans in help screen result bubbles
djsrv Jun 13, 2019
14125eb
Move more help screen code to help.js
djsrv Jun 17, 2019
6e032d8
Move help code to libraries
djsrv Jun 24, 2019
fc6baed
Complete Help translator library
djsrv Jun 25, 2019
75648c2
Add help screen sources
djsrv Jun 25, 2019
d557f4a
Merge branch 'master' into help-screens
djsrv Jun 25, 2019
938ec12
Move old help files
djsrv Jun 25, 2019
a29dda3
Update Help translator library
djsrv Jun 25, 2019
fe1d2fa
Add new rendered help screens
djsrv Jun 25, 2019
0567bf1
Avoid caching help screen sources
djsrv Jun 25, 2019
dbe76ae
Add guide on translating help screens
djsrv Jun 25, 2019
44e4ecf
Fix script diagram fixLayout
djsrv Jul 4, 2019
765f3b3
Allow blocks to be ghosted in help screens
djsrv Jul 4, 2019
ce450b5
Add more help screens
djsrv Jul 4, 2019
ac7078a
Add black box for doWarp help screen
djsrv Jul 13, 2019
4e3eac4
Add script scaling to help screens
djsrv Jul 13, 2019
9b28fdb
Prevent arrow overlap in diagrams
djsrv Jul 13, 2019
5d47fe5
Help screen cleanup
djsrv Jul 13, 2019
a44bba0
Allow list inputs to be annotated in diagrams
djsrv Jul 13, 2019
5026c10
Add error handling to help screen blocks
djsrv Jul 13, 2019
c2187cb
Add more help screens
djsrv Jul 13, 2019
cd71495
Merge branch 'master' into help-screens
djsrv Jul 15, 2019
53839f8
Fix a comment
djsrv Jul 16, 2019
d4c3fb1
Add shadows to bubbles in diagrams
djsrv Jul 16, 2019
121bf4e
Fix a bug with bubbles in diagrams
djsrv Jul 16, 2019
b447a2f
Update help screens
djsrv Jul 16, 2019
b7dd5a4
Add documentation of help screen XML
djsrv Jul 16, 2019
ca4b1ef
Lint and license help.js
djsrv Jul 16, 2019
eae4167
Fix XML.md
djsrv Jul 16, 2019
a74a39a
Capitalize title of TRANSLATING.md
djsrv Jul 31, 2019
2e68116
Apply suggested improvements to TRANSLATING.md
djsrv Jul 31, 2019
6494d75
Replace whitespace instead of split+join in help.js
djsrv Jul 31, 2019
0d24966
Remove or rename variables named "screen"
djsrv Jul 31, 2019
9e56c0a
Rename processText to normalizeWhitespace
djsrv Jul 31, 2019
076c933
Use ide.resourceURL to get image resource URL
djsrv Jul 31, 2019
752d1f6
Rename TRANSLATING.md to README.md
djsrv Jul 31, 2019
29a7b85
Make early return in showBubble clearer
djsrv Aug 4, 2019
624d81d
Fix to last commit
djsrv Aug 4, 2019
283a82c
Combine loading of old and new help screens
djsrv Aug 4, 2019
5c2a076
Load blocks from libraries in help screens
djsrv Aug 8, 2019
9a835f2
Fix script-in-script arrows in diagrams
djsrv Aug 8, 2019
4f81b96
Update help screen font with libre alternative
djsrv Dec 5, 2019
1e47a34
Make sure help screens are rendered at double size
djsrv Dec 19, 2019
b5cba01
Fix help screen typos
djsrv Dec 19, 2019
8eb444f
Add arrow-horizontal attribute for help annotations
djsrv Dec 23, 2019
fdbecbe
Improve behavior of help screen text within rows
djsrv Dec 23, 2019
67369c2
Don't make help screen text unnecessarily wide
djsrv Dec 27, 2019
cec7e58
Fix zebra coloring in help screen block definitions
djsrv Dec 27, 2019
8157f28
help screen changes
brianharvey Dec 22, 2019
5785186
Complete bh help edits
brianharvey Dec 28, 2019
14eac6f
Help screen cleanup
djsrv Jan 11, 2020
7b8f064
Improve help screen element width handling
djsrv Jan 11, 2020
e558402
Fix help screen bubble rendering
djsrv Jan 14, 2020
b028525
Properly implement nested help boxes and headers
djsrv Jan 14, 2020
73903d7
Allow custom fonts in help screens
djsrv Jan 15, 2020
682a17c
Update XML.md
djsrv Jan 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
103 changes: 103 additions & 0 deletions help/TRANSLATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Translating help screens:
djsrv marked this conversation as resolved.
Show resolved Hide resolved

See CONTRIBUTING.md for a general guide on translating.
djsrv marked this conversation as resolved.
Show resolved Hide resolved

## 1. Setup

If you haven't already downloaded a copy of the Snap! source, go to
<https://github.com/jmoenig/Snap> and click "Clone or download".
djsrv marked this conversation as resolved.
Show resolved Hide resolved

For the Help translator library to work, you'll need to put Snap! on a local HTTP
server. See <https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server#Running_a_simple_local_HTTP_server>
djsrv marked this conversation as resolved.
Show resolved Hide resolved
for an example of how to do this.

Create a copy of the `en` directory in the `help` directory, naming it the
two-letter ISO 639-1 code for your language (see
djsrv marked this conversation as resolved.
Show resolved Hide resolved
djsrv marked this conversation as resolved.
Show resolved Hide resolved
<http://en.wikipedia.org/wiki/ISO_639-1>).

## 2. Translation

Replace the English text in the XML files with the translated text.

The translated versions of block labels will be used automatically. For example,
djsrv marked this conversation as resolved.
Show resolved Hide resolved
`<block s="show"/>` should be left as-is.

Block inputs are not automatically translated unless enclosed in `<option>` tags.
For example:
```
<block s="bubble">
<l>Hello world!</l>
</block>
```
will not be automatically translated and should be manually changed to
```
<block s="bubble">
<l>¡Hola!</l>
</block>
```
while
```
<block s="getEffect">
<l><option>ghost</option></l>
</block>
```
will be automatically translated and should be left as-is.

You may have to adjust the widths of columns, which are specified as a ratio using
the `rel-width` attribute. For example, you may want these columns' widths to be
1:1 in English:
```
<row>
<column rel-width="1">
<script>
...
</script>
</column>
<column rel-width="1">
<script>
...
</script>
</column>
</row>
```
but 2:1 in another language:
```
<row>
<column rel-width="2">
<script>
...WIDER SCRIPT...
</script>
</column>
<column rel-width="1">
<script>
...NARROWER SCRIPT...
</script>
</column>
</row>
```

Replace images where applicable.

## 3. Rendering

Open your local copy of Snap!, and switch it to your language.

Import the `Help translator` library (at the bottom of the Libraries menu).

Note: `ENABLE HELP TRANSLATOR` is run automatically when you render a help screen,
so doing this manually is not necessary.

To render a single block, run `download help screen for spec [spec]` or
`download help screen for [lambda]`. For example: `download help screen for spec [forward]`
or `download help screen for [move (10) steps]`. This will download the help screen
for this block as a PNG file.

To download all help screens, run `download all help screens`. This will render
every help screen and download them as a ZIP file.

Place the rendered PNG files in your language's help folder.

# Adding new help screens:

After adding a new XML file to a language's folder, add the block's selector to the
`HELP` file so that `download all help screens` can find it.
236 changes: 236 additions & 0 deletions help/XML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
# Help Screen XML

## Structure

```
<help-screen version="1">
<blocks>
<!-- Optional -->
<!--
Put custom block definitions here so the blocks can be used in
the help screen. These can be copied and pasted from
projects or libraries.
-->
</blocks>
<thumbnail>
<!--
Usually a script that will be displayed in the top-left of the
help screen
-->
</thumbnail>
<box color="gray">
<!-- Main content box -->
</box>
<box color="blue">
<!-- Additional boxes can be added below... -->
</box>
</help-screen>
```

## Layout Elements

### `<box>`

A box that contains the helps screen's content. Usually it should contain an
alignment element (`<row>` or `<column>`) to specify how content should be
arranged:
```
<box color="gray">
<column>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
</column>
</box>
```

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| color | "gray", "black", "blue" | "gray" | The background color. |

### `<row>`

Aligns its contents in a row.

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| padding | number | 15 | How far apart the content elements are. |

Some elements, like `<script>`, have a fixed width, while others, like `<p>`,
have a variable width. By default, variable-width elements are their parent's
width:
```
<column>
<p>I am my parent's width.</p>
<p>I am also my parent's width.
</column>
<row>
<p>I am my parent's width.</p>
<p>I am also my parent's width. That doesn't work well in this context.</p>
</row>
```

The `rel-width` (relative width) attribute can be used to change this, by
specifying elements' widths as a ratio. For example, the widths of these
elements are 2:1:
```
<row>
<p rel-width="1">I am one-third my parent's width.</p>
<p rel-width="2">I am two-thirds my parent's width.</p>
</row>
```

If fixed and variable-width elements are mixed, the fixed-width elements take
up whatever space they need, and the remaining space is divided among the
variable-width elements:
```
<row>
<img src="image.png" width="100" height="100"/>
<img src="image.png" width="100" height="100"/>
<p rel-width="1">My width is 1/4 * (parent's width - 100 - 100)</p>
<p rel-width="3"> My width is 3/4 * (parent's width - 100 - 100)</p>
</row>
```

### `<column>`

Aligns its contents in a column.

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| padding | number | 10 | How far apart the content elements are. |

## Content Elements

### `<p>`, `<small-p>`, `<i>`, `<small-i>`

Paragraph elements. `<p>` is normal text, while `<i>` is italic. The default
font size is 18px, while the small variants are 14px.

These elements can be used in two ways. One:
```
<p>This paragraph contains just text.</p>
```

Two:
```
<p>
<text>This paragraph contains text and other elements</text>
<script>
<block s="forward">
<l/>
</block>
</script>
<text>which are inlined.</text>
</p>
```
| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| rel-width | number | none | See `<row>`. |

### `<img>`

An image.

| Attribute | Value | Default |
| --- | --- | --- |
| src | a file path, relative to the language's help directory | none |
| width | number | none |
| width | number | none |

### `<script>`

A script. This can just be copied and pasted from a project.

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| scale | number | 1 | Changes the size of the script. Only works when in a diagram. |

### `<block-definition>`

Displays a custom block definition, taken from the `<blocks>` element.

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| s | the custom block's spec | none | This is the same block spec used in `<custom-block>` elements in a `<script>`. |
| scale | number | 1 | Changes the size of the script. Only works when in a diagram. |

### `<menu>`

Can be used to replicate an input or context menu:
```
<menu>
<item>One</item>
<item>Two</item>
<line/>
<item>Three</item>
</menu>
```

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| no-empty-option | true or false | false | By default the menu has an empty option at the top. |

### `<item>`

A menu item.

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| color | a CSS color | none | Changes the item's background color. |

### `<diagram>`

A diagram of a script:
```
<diagram>
<script>
<block s="xPosition" annotation="1" bubble="1"/>
</script>
<annotations>
<small-p>Annotation</small-p>
</annotations>
<bubbles>
<text>0</text>
</bubbles>
</diagram>
```
or a menu:
```
<diagram>
<menu>
<item>menu item</item>
</menu>
<annotations>
<small-p>Annotation</small-p>
</annotations>
</diagram>
```

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| rel-width | number | none | See `<row>`. |

Attributes for script/menu components:

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| annotation | number | none | The component will be annotated with the nth element in the annotations list (1-indexed). |
| bubble | number | none | Blocks only. The block will have a bubble containig the nth element in the bubbles list (1-indexed). |
| highlight | true or false | false | Blocks and inputs only. If true, the component will have a green highlight. |
| ghost | true or false | false | Blocks only. If true, the block will be ghosted. |
| arrow-start | number | none | An arrow will be drawn to the component with the corresponding arrow-end ID. These IDs should start at 1 and are separate from the annotation IDs. |
| arrow-end | number | none | |

Attributes for annotations and `arrow-start` components:

| Attribute | Value | Default | Comment |
| --- | --- | --- | --- |
| arrow-reverse | true or false | false | Reverses the arrow. |
| arrow-detour | number | 0 | The arrow will bend by this many pixels. This attribute can be used to prevent the arrow from overlapping important parts of a script. |
| arrow-color | CSS color | black/white | Default depends on the color of the box the diagram is contained in. |

Valid bubble contents:
- `<text>Text</text>`
- `<bool>true</bool>`
- `<bool>false</bool>`
- `<img .../>`
Loading