[PATCH 0 of 9 ] prevent translation for some rst syntax

Martin Geisler martin at geisler.net
Thu Feb 20 13:42:58 CST 2014

Simon Heimberg <simohe at besonet.ch> writes:

> Am 08.02.2014 12:17, schrieb Martin Geisler:
>> Simon Heimberg <simohe at besonet.ch> writes:
>> Great stuff! If we try to move to the long
>>    .. note::
>>       This is the note.
>> syntax, then the translators will be almost completely shielded from
>> the rst syntax.
> We already do this in the code. There is a check-code rule for this.

That's very nice!

> But obviously we don't do it in mercurial/help/*.txt. I have sent a
> patch which is already applied.

I think your patch looks good.

>> I think we could still lookup the right text at translation time by
>> stripping leading whitespace, do the lookup, and then adding it
>> afterwards -- this is actually just like how we split paragraphs.
>> The advantage would be that translators seen even less rst syntax and
>> wont have to deal with keeping the indentation consistent.
> Very interesting idea!
> some steps to go:
>  * add a test for posplit (in preparation)
>  * find and fix some corner cases
>  * teach posplit to remove indentation
>    (keeping all comments, not generating double entries)
>  * teach mercurial to use this translations
>    * in mercurial.i18n
>    * or when generating xx.mo
>  * (maybe restart from step 3 and teach posplit to do it even better)
> Some questions:
> = different indentation =
> What should we do with such a paragraph?
> "    aaa\n"
> "        bb"
> Probably convert to this?
> "aaa\n"
> "    bb"

Yeah, that's what I would expect.

> Probably not to the following, because we can not know when the
> indentation should occur in the translation. (The number of lines can
> vary to the original.)
> "aaa\n"
> "bb"

I agree.

> = corner case: command options =
> Command options need special handling.
> translated is this:
> "this option does something very interesting with"
> it is shown like this (in hg help):
>  -x --example       this option does something very interesting with
> When the translation is much longer than the original, we need a line
> break.

Is that not already working today? I thought minirst would reformat the
help texts according the width of the widest option? It's a very long
time I looked at this code, though.

> But the 2nd line must start intended. This is not visible form the
> original, so do not bother the translator with this. I prepare a patch
> series handling this in mercurial.minirst.maketable (for hg help) and
> in gendoc.get_opts (for generating documentation).

Apparently not :-)

> No idea if there are similar problems in other places. Anybody knows
> about one?
> = when to look up indented =
> Instead of removing and adding the spaces on runtime, we could also do
> this when generating xx.mo (by generating it form a temporary
> indented_xx.po.tmp). But not sure if this is nicer.

That sounds more complicated to me. The code here is not in an inner
loop, performance is not critical, so I think we affort to remove/add
the whitespace at runtime.

Martin Geisler

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140220/ff50ce0a/attachment.pgp>

More information about the Mercurial-devel mailing list