website
website copied to clipboard
Extract markdown from content pages into localization jsons
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 thesrc/content/LANG/PAGE.md!!! - changes to md pages can be extracted to json using
yarn extract-content. Script will read all *.md pages insrc/contentand REPLACEcontent.PAGEkeys insrc/locales/LANG.jsonwith new values (extracted fromPAGE.md). Other keys are not overriden, but file might be reformatted (effect ofJSON.parseandJSON.stringify). Keep in mind this is no 2way sync, so extract will override changes from weblate. See TODO - Functionality of
StaticPageremains the same, but there is newTranslatableStaticPagethat takes single proplocaleKey
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/contentjust 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.
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
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.
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.
Yes, that would be better
Also we have many .md pages placeholders, so we shouldn't put those in translations