Le jeudi 20 juin 2013 à 17:20 +0200, Robert Lehmann a écrit :
> Hi Claude,
Hi Robert,
> I'd propose pulling full-text comments out of code, replacing them
> with footnotes or markers instead:
>
>
> questionable_code_line() # <--
>
> another_one() # (1)
This might be a solution in certain cases, but not in our particular use
case, where pages can be rather long. It'd lower the general readability
of the document and would never be accepted by English writers.
Moreover, it doesn't address translatability of strings inside
parameters.
> I think having any kind of markup in the msgids is a source for error.
> Same for code.
Sure, I understand, but we have already reSt markup in the current i18n
infrastructure. We should tend for less markup when possible, but
anyway, I'd rather have a markup-encumbered string than no translatable
content.
> Also, combining multiple code lines into one msgid will only cause
> unhappiness.
Maybe, maybe not. As translator, I'm happy when I have content to
translate!
> I like the idea of automatically extracting comments only — I'd be
> happy to review a patch! — but consider it non-trivial. First off,
> we'd probably want to care for multiple languages (ie., commenting
> styles.) Also, code comments cannot be easily wrapped so that lines
> might be unreasonably inflated/deflated in translations.
>
> We could theoretically re-use Pygments' tokenization, but that's
> already imperfect in cases like Python's multi line comments. A quick
> test revealed it also does not separate comment markers from the
> comment string, so that we *would* have to special-case every language
> (or, do some black magic to extract the comment characters, think /*
> comment */, from Pygments' lexer description.) On the upside, it
> distinguishes between docstrings and normal strings. On the downside,
> docstrings are extra hard anyways because they *can* contain
> structured markup.
I also briefly explored the automatic extracting of comments, and indeed
there are many technical challenges to solve.
That's why my proposal was less ambitious, at the expense of being a
little less translator-friendly in the translatable strings.
Thanks for you input!
Claude