Hi, I'm currently writing a library, and I'd like to translate its documentation into Chinese. Is there a structured method for writing documentation in multiple languages, or do I just need to write it in multiple languages within the same Nimdoc comments?
Alternatively, I suppose I could create the equivalent of a header file with the nimdocs for the other languages, but that doesn't sound very maintainable.
Any pointers or suggestions are appreciated.
I have no idea if this works, but as an idea maybe you could do:
proc foo*() =
when defined(englishDocs):
## English docs here
when defined(chineseDocs):
## Chinese docs here
then build docs with nim doc -d:englishDocs foo.nim for English doc pages, and nim doc -d:chineseDocs foo.nim for Chinese doc pages.
To make it less strict (i.e. for docs to work in IDE) you could check for defined(englishDocs) or not defined(nimdoc).
It looks like my best bet would be to do as @Hlaaftana and @PMunch suggested and add a when statement, or create a macro.
@federico3 I'm surprised Araq was against translation in the RFC linked. I know for a fact that I can maintain documentation in 2 languages for my own project, so it should definitely be a docgen feature, even if it's not something that the stdlib gets use out of.
That's hard to maintain, though. Perhaps you can maintain the Chinese documentation in the separate directory => https://github.com/iocrate/netkit/blob/master/doc/zh/code/netkit/buffer/circular.nim
https://github.com/iocrate/netkit/blob/5860c6dab1dc93d5a344e16288757c20e690b590/config.nims#L41