mdTranslation icon indicating copy to clipboard operation
mdTranslation copied to clipboard

Splitting translation files for mdBook preprocessor

Open ISSOtm opened this issue 3 years ago • 0 comments

Hi! I'm looking to use mdTranslation and mdbook-translation for ISSOtm/gb-asm-tutorial#25.

Unfortunately, given that the book is quite large, a single translation file per language is infeasible, much less so one for all translations (as nice as the "many languages per translation file" feature is, I don't think it's useful for this use case). Hence, I would prefer if the preproc read one translation file per input file (i.e. the translation files would be arranged following the same structure as the book's source).

Here's a command to generate the translation files:

$ git ls-files -z src | sed -Ez 's,src/(.+\.md)$,\1,;t;d' | xargs -0I {} bash -c 'mkdir -p "$(dirname "translations/@@LANG@@/{}")" && mdtranslation_extract -l @@LANG@@ "src/{}" >"translations/@@LANG@@/{}"'

(Replacing @@LANG@@ with the language of your choice, of course.)

Would you be interested in upstreaming such changes?

ISSOtm avatar Aug 12 '22 22:08 ISSOtm