Slicer / SlicerLanguagePacks

3D Slicer extension for creating, editing, and storing translations for Slicer core and extensions
MIT License
7 stars 11 forks source link

Set up infrastructure for documentation translation #18

Open lassoan opened 1 year ago

lassoan commented 1 year ago

Evaluate slideshow generation tools, see for example: https://tiiny.host/blog/the-ultimate-list-of-markdown-presentation-tools/

lassoan commented 1 year ago

Presentation that could be used in the software evaluation pilot: https://github.com/PerkLab/PerkLabBootcamp/blob/master/Doc/day1_2_DataLoadingAndVisualizationTutorial.pptx

Automatic annotation of screenshots:

Example:

Source text:

![SomeImage | [{"type"="clickMarker", "position": "updateButton", "label": "1"}] ](image.png)

Processed text that displays the annotated image:

![SomeImage](image_234234.png)
lassoan commented 1 year ago

Try to set up github actions to automate generation and deployment of github pages: https://github.com/ralexander-phi/marp-to-pages

Have a look at more complex examples, such as:

Write more slides of DataLoadingAndVisualizationTutorial.pptx.

For the future: Implementing custom image processing (e.g., add mouse click marker and labels), check if it is possible to add custom image processing plugins; if not then we can parse the markdown file (https://github.com/syntax-tree/mdast), preprocess it, update the image source, and use marp on the preprocessed markdown and images.

lassoan commented 1 year ago

Testing repository: https://github.com/Adama-WADE/Tutorial-Translation

Side-by-side image and text:

Two columns: https://github.com/orgs/marp-team/discussions/192?#discussioncomment-1516155 (need to Enable HTML in Marp Markdown)

Image sizing: need to specify in pixels? https://github.com/orgs/marp-team/discussions/167

lassoan commented 1 year ago

Meeting 20230410

Todo:

.h file created from .md by a script similar to update_translations.py:

// Slide 1
// from VotingBinaryHoleFillingImageFilter.xml
// {"filename": "filename.md", "startRow": 356, "startColumn": 23, "endRow": 357, "endColumn": 40}
QT_TRANSLATE_NOOP("VisualizationTutorial", "3d slicer logo")
// {"filename": "filename.md", "startRow": 356, "startColumn": 23, "endRow": 357, "endColumn": 40}
QT_TRANSLATE_NOOP("VisualizationTutorial", "3D Slicer")
// {"filename": "filename.md", "startRow": 356, "startColumn": 23, "endRow": 357, "endColumn": 40}
QT_TRANSLATE_NOOP("VisualizationTutorial", "Data Loading and <br> Visualization Tutorial")

// Slide 2
// {"filename": "filename.md", "startRow": 356, "startColumn": 23, "endRow": 357, "endColumn": 40}
QT_TRANSLATE_NOOP("VisualizationTutorial", "Please download the following dataset:")

// Slide 3
// {"filename": "filename.md", "startRow": 356, "startColumn": 23, "endRow": 357, "endColumn": 40}
QT_TRANSLATE_NOOP("CLI_VotingBinaryHoleFillingImageFilter", "This command module was derived from Insight/Examples/Filtering/VotingBinaryHoleFillingImageFilter (copyright) Insight Software Consortium")

https://waylonwalker.com/python-markdown-ast-paragraph/

with open(r'c:\D\Tutorial-Translation\Marp.md', 'r') as fin:
    md = fin.read()

import commonmark
import json
parser = commonmark.Parser()
ast = parser.parse(md)

# Json representation is simple but does not include source location
jsonRoot = json.loads(commonmark.dumpJSON(ast))
for item in jsonRoot:
    if item['children']:
        for childItem in item['children']:
            if "literal" in childItem:
                print(childItem["literal"])

# AST object API is more complicated but necessary, as it includes row/column information for each block
commonmark.dumpAST(ast) # pretty print generated AST structure

paragraphs = ''
for node in ast.walker():
    if node[0].t == "paragraph":
        paragraphs += " "
        if node[0].first_child.literal:
            paragraphs += node[0].first_child.literal + "\n"
Adama-WADE commented 1 year ago

extract_strings.py:

lupdate:

translate_strings:

Adama-WADE commented 1 year ago

Refer to the following commit fort the resolution of tasks listed in the issue comment above