website icon indicating copy to clipboard operation
website copied to clipboard

Extract markdown from content pages into localization jsons

Open overlordtm opened this issue 5 years ago • 5 comments
trafficstars

This change make it possible to translate content pages into jsons, to be translated using Weblate.

Changes:

  • source of static pages is now src/locales/LANG.json, not the src/content/LANG/PAGE.md !!!
  • changes to md pages can be extracted to json using yarn extract-content. Script will read all *.md pages in src/content and REPLACE content.PAGE keys in src/locales/LANG.json with new values (extracted from PAGE.md). Other keys are not overriden, but file might be reformatted (effect of JSON.parse and JSON.stringify). Keep in mind this is no 2way sync, so extract will override changes from weblate. See TODO
  • Functionality of StaticPage remains the same, but there is new TranslatableStaticPage that takes single prop localeKey
const routes = [ ...
      {
        path: 'faq',
        component: TranslatableStaticPage,
        props: { localeKey: 'content.faq' }
      },
...]

As consequence, router.js is much simplified :)

TODO:

  • Test it everytwhere (mobile)
  • IMHO we should extract src/content just once and then remove it from source tree and just have it in Weblate (if weblate has decent markdown support?). This way we avoid problems if content is changed in md file and in weblate.

overlordtm avatar Oct 13 '20 23:10 overlordtm

I suggest we:

  • do just the json reordering once separately, before doing this, so the changes will be minimized. If there are other (eg indentation/encoding) differences we should try to eliminate them.
  • enable project forks to still do their translations, but now in weblate instead of .md files, preferably using contexts (eg MKD/ faq.md (we should check we have the latest ones from their forks!) content should get into pages.faq_MKD key)
  • delete .md files

stefanb avatar Oct 14 '20 05:10 stefanb

Reordering keys in JSONs will cause conflicts with all branches that have these JSONs changed, so it should be done at just the right time, coordinated with other branch owners.

stefanb avatar Oct 14 '20 22:10 stefanb

I would suggest we find all open PR-s that have *.md files modified. We merge them, then I rebase on latest master, run extraction again (commit only additional keys, without reordered), remove original *.md files and merge this? This way we will end up only with additional keys in localization json-s, I think git should handle that.

overlordtm avatar Oct 18 '20 18:10 overlordtm

Yes, that would be better

stefanb avatar Oct 18 '20 19:10 stefanb

Also we have many .md pages placeholders, so we shouldn't put those in translations

stefanb avatar Oct 18 '20 19:10 stefanb