tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
372 stars 102 forks source link

Proposal: Grand Docs Migration #869

Closed novusnota closed 12 hours ago

novusnota commented 5 days ago

Goals

Other options considered

Docusaurus:

VuePress:

Solution

Starlight — an Astro-powered documentation framework, that allows for great extensibility and bundles (among other things): advanced i18n support via i18next, site navigation, search, SEO, easy-to-read typography, code highlighting, dark mode and more. Also, it's very lightweight.

Extra pros discovered:

Cons discovered:

About i18n and translations

All the UI elements have built-in translations to a lots of languages, including Chinese and Simplified Chinese, so we don't have to translate those, only the content of the pages.

Regarding that, one path we might take with Starlight and Crowdin (for translations) may look as follows:

  1. We use https://store.crowdin.com/i18next-json built-in format, and export files in .json according to i18next-json structure
  2. We add those files from time to time over to src/content/i18n/ folder in Starlight docs
  3. On the non-English .mdx pages instead of the "raw" text we place calls to Astro.locals.t() and pass the keys from the files from step 2.

The big issue with that approach arises from the volatile nature of Tact docs — texts get changed often and even whole paragraphs can appear and disappear at times. Containing that complexity within the keys in .json files puts WAY too much maintainance burden on the translators. Besides, those are just inconvenient to write since the whole picture of the text would be hidden away, allowing only single phrases or paragraphs to be translated at the time, lacking the larger context of the whole page.

My proposal is simple — just use the .mdx files for the translations. Crowdin already supports the .mdx format out of the box (including YAML or TOML frontmatters, see: https://store.crowdin.com/mdx), so we can:

  1. Put .mdx files onto Crowdin for translators
  2. Pull translated files from it from time to time (like, once a month or so)
  3. Place those files under src/content/docs/zh-cn (for Simplified Chinese) and that's it

Now, regarding sidebar and the translations of titles — nothing extra has to be done there! If we use internal links (i.e. just names of the files, which must stay the same in all localizations), we get the localized titles out of content frontmatters of translated pages for free. See: https://starlight.astro.build/guides/sidebar/#internationalization-with-internal-links.

P.S.: I believe that all technical writers and translators must know Markdown and bits of HTML and YAML to be able to figure MDX out in less than an hour, really. And giving more context (i.e. full file instead of the disjoint set of strings/lines) to translators is ALWAYS a plus.

Steps

anton-trunov commented 5 days ago

By default, there's no highlighting of inline code blocks and no existing plugins for it yet. Local implementation went rather smooth, wasn't a big deal

What does it mean "Local implementation went rather smooth"?

novusnota commented 4 days ago

What does it mean "Local implementation went rather smooth"?

I just wrote a small rehype plugin (a single file with <100 lines with comments) and included it into the astro.config.mjs. Tested, debugged, and then achieved the same (theme and all) inline code highlighting, as it's seen in Nextra framework in the current Tact docs.

P.S.: Inline code highlighting means this gets highlighted, not:

this

Which is a code block highlighting :)