Best way to manage long links to external url with an explicit title

70 views
Skip to first unread message

ThomasG

unread,
Nov 15, 2013, 8:52:19 PM11/15/13
to sphinx...@googlegroups.com
Hi all,

I'm looking to a way to use an explicit title with a long link that point to an external URL.
The context is within an existing sphinx project based on Sphinx where I'm starting to use internationalization.

For the moment, the doc uses:

`My title is cool`_
 
and make a reference
.. _`My title is cool`: http://hyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyper.org

But when I make the translation using i18n, the .po file looks

#: myfile/mynewfile.txt:120
# 0b980b6a3364440bb7bf15ca94a1256c
msgid "`My title is cool`_"
msgstr "`Mon titre est cool`_"

For this reason, English (original) doc is ok but French loses the link after I applied internationalization

I know I can do as an alternative:
`Link text <http://example.com/>`_ but I have a lot of URL with 350 characters so inline url not the way I want when I need to update links.

Do you know a better way to solve my use case or I'm stuck with the inline markup solution?

Thanks for any feedback
Cheers

Thomas






Takayuki Shimizukawa

unread,
Nov 16, 2013, 1:14:53 AM11/16/13
to sphinx...@googlegroups.com
Hi Thomas,

It's a good question. I have no answer for that yet.
There is a similar issue:
https://bitbucket.org/birkenfeld/sphinx/issue/1265/crash-when-translating-link-to-another

As a workaround, the anonymous target notation could be used.

---------

`this is one`__ and `this is two`__ is the sequential anonymous link target.
It works fine with i18n translation if you keep link target order.

.. __: http://example.com/one
.. __: http://example.com/two

---------

It works fine, but there is one limitation.
The translator must keep link target order.

Any help/suggestion/patch is welcome :)

Regards,
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa


2013/11/16 ThomasG <osgeo.ma...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/groups/opt_out.

Thomas Gratier

unread,
Nov 16, 2013, 2:59:30 PM11/16/13
to sphinx...@googlegroups.com
Hi,

I will have to choose the `Link text <http://example.com/>`_ solution for 2 reasons:
*my .po file is more than 13000 lines so keeping order of links will not be possible.
*I'm using French so "my dog's friend" become "l'ami de mon chien" where "chien" is "dog" and "ami" is "friend". It means order of the words are reversed in lot of sentences and I can't really avoid losing links order.

Thanks anyway for your detailled answer

Cheers

Thomas


2013/11/16 Takayuki Shimizukawa <shimi...@gmail.com>
You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sphinx-users/rujpFXC3AB8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sphinx-users...@googlegroups.com.

Guenter Milde

unread,
Nov 17, 2013, 12:39:21 PM11/17/13
to sphinx...@googlegroups.com
On 2013-11-16, ThomasG wrote:

> I'm looking to a way to use an explicit title with a long link that point
> to an external URL.
> The context is within an existing sphinx project based on Sphinx where I'm
> starting to use internationalization.

> For the moment, the doc uses:

> `My title is cool`_

> and make a reference
> .. _`My title is cool`:
> http://hyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyper.org

> But when I make the translation using i18n, the .po file looks

> #: myfile/mynewfile.txt:120
> # 0b980b6a3364440bb7bf15ca94a1256c
> msgid "`My title is cool`_"
> msgstr "`Mon titre est cool`_"

> For this reason, English (original) doc is ok but French loses the link
> after I applied internationalization

You could add an alias (indirect `hyperlink target`_) like::

`My title is cool`_

.. _`My title is cool`: cooltitle_

.. _cooltitle:
http://hyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyper.org


or use an `embedded alias`_:

`My title is cool <cooltitle_>`_

.. _cooltitle:
http://hyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyperlongurlhyper.org


Günter

.. _hyperlink target:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets

.. _embedded alias:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases



Thomas Gratier

unread,
Nov 17, 2013, 2:35:27 PM11/17/13
to sphinx...@googlegroups.com
Hi all,

Thanks Günter, I'm now using your second solution doing like below

en original file (unchanged):

`My title is cool`_



#: myfile/mynewfile.txt:120
# 0b980b6a3364440bb7bf15ca94a1256c
msgid "`My title is cool`_"
msgstr "`Mon titre est cool <My title is cool_>`_"


I choose this second solution because the first one will lead to create a second reference in original en file. This behaviour is "wrong" in my case: I don't want to put constraint on original English content to the English authors and mix languages (and make translation too intrusive).

As an example, en file would contain :


`My title is cool`_

  .. _`My title is cool`: cooltitle_



#: myfile/mynewfile.txt:120
# 0b980b6a3364440bb7bf15ca94a1256c
msgid "`My title is cool`_"
msgstr "`Mon titre est cool`_"

Thanks for all those valuable inputs
Cheers

Thomas


2013/11/17 Guenter Milde <mi...@users.sf.net>

Guenter Milde

unread,
Nov 18, 2013, 4:10:58 AM11/18/13
to sphinx...@googlegroups.com
On 2013-11-17, Thomas Gratier wrote:

> I choose this second solution because the first one will lead to create a
> second reference in original en file. This behaviour is "wrong" in my case:
> I don't want to put constraint on original English content to the English
> authors and mix languages (and make translation too intrusive).

> As an example, en file would contain :

Why not:
and the .po file::

#: myfile/mynewfile.txt:120
# 0b980b6a3364440bb7bf15ca94a1256c
msgid "`My title is cool`"
msgstr "`Mon titre est cool`"

to change both, reference and (indirect) target.

Günter

Reply all
Reply to author
Forward
0 new messages