mljar / mercury

Convert Jupyter Notebooks to Web Apps

Home Page:https://RunMercury.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

localization support

wentzlau opened this issue · comments

It would be great if there were support for localization.

In the header there should be a language selector.

The localized text should be in a folder structure:

languages
    uk
        welcome.md
        tos.md
        privacy.md
        notebook_1.md
        notebook_2.md
   dk
      welcome.md
      tos.md
      privacy.md
      notebook_1.md  
      notebook_2.md   

Each notebook has a markdown file that is matched by its name. The notebook markdown file consists of sections that can be referenced by a new function mercury.get_text.

Content of a markdown file

===section 1===
# This is first section

A markdown paragraph
===
===section 2===
# This is the second section

Another paragraph
===
===section 3===
Graph shows values for the year {year}
===

In a notebook cell call the function mercury.get_text("section 1") that returns a section as a string.

There should be support for placeholders passed as a dictionary something like mercury.get_text("section 3", { year: 2023 }) that returns a string with expanded values "Graph show values for the year 2023"

It is best to separate the localized text from the notebook as it is easier to hand over the markdown files to translation than a notebook with code to confuse.