Difference between revisions of "Template:Anchor"

From Sugar Labs
Jump to navigation Jump to search
(New page: <includeonly><span id="{{{1}}}"></span></includeonly><noinclude>Category:Template This template is used to create an anchor without requiring a specific (sub) section header to be made...)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<includeonly><span id="{{{1}}}"></span></includeonly><noinclude>[[Category:Template]]
 
<includeonly><span id="{{{1}}}"></span></includeonly><noinclude>[[Category:Template]]
This template is used to create an anchor without requiring a specific (sub) section header to be made.
+
This template creates an HTML anchor without creating a visible section header or a TOC entry.
  
The main purpose is to allow the translation of links without interfering in the translation of content. The most usual 'problem' arising when translating is that some section titles are much less immutable than the original. For example, in the [[HIG]] there's the concept of [[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor#Home|Home]]. The word itself may have several possible translations in a given language, and one may be prefered to others but may not have been the 'initial' choosing. In later revisions, the header could be changed for a ''better wording'', but then all the links pointing to it would be broken.  The solution is to use this template as the ''anchor'' for the original language header.
+
Its main use is to allow the translation of links without interfering with the translation of content. The most usual 'problem' arising when translating is that some section titles are much less immutable than the original. For example, in the [[Human Interface Guidelines]] there's the concept of [[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor#Home|Home]]. The word itself may have several possible translations in a given language, and one may be preferred to others but may not have been the 'initial' choosing. In later revisions, the header could be changed for a ''better wording'', but then all the links pointing to it would be broken.  The solution is to use this template as the ''anchor'' for the original language header.
  
; Example : In a page you are translating there's the following link:
+
== Example ==
 +
In a page you are translating there's the following link to a section:
 +
<nowiki>[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor#Home]]</nowiki>
 +
You know the translated page will be named
 +
Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx
 +
You want to leave the link as
 +
<nowiki>[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx#Home]]</nowiki>
 +
so you don't have locate the translated section text and change the link to use it.
  
          <nowiki>[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor#Home]]</nowiki>          # Original link
+
If the page you are linking to uses [[Template:Anchor]] then you can do this;
            OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx          # Translated page
+
the linking of translated pages (and their sections) can be done regardless of how the ''Home'' section header was translated &mdash; in [[olpc:Spanish language| spanish]] it could be translated as either ''[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|Hogar]]'' or ''[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|Casa]]''&mdash;both actually linking to the ''anchor'' [[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|#Home]] and will both work.
          <nowiki>[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx#Home]]</nowiki>  # Translated link
+
: It's also possible to link the translated section heading, for example''[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Hogar|#Hogar]]'' or ''[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Casa|#Casa]]''&mdash;but in this case, one of them will not work.
 
 
: The linking of translated pages (and their sections) can be done regardless of how the ''Home'' section header was translated &mdash; in [[spanish]] it could be translated as either ''[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|Hogar]]'' or ''[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|Casa]]''&mdash;both actually linking to the ''anchor'' [[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Home|#Home]] and will both work.
 
: It's also possible to link the translated terms ''[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Hogar|#Hogar]]'' or ''[[OLPC Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-es#Casa|#Casa]]''&mdash;but in this case, one of them will not work.
 
  
 
== Usage ==
 
== Usage ==
Line 27: Line 31:
 
== History & Credits ==
 
== History & Credits ==
  
The concept of ''anchor'' is essential to hypertext. The adaptation of using <tt>&lt;div id="original header"/&gt;</tt> (a ruthless hack) was done by [[User:Xavi|Xavi]] after discovering that the <tt>&lt;a&gt;</tt> is not allowed.  That solution broke down after an update of the wiki. The solution was to switch to an html compliant <tt>&lt;div id="original header"&gt;&lt;/div&gt;</tt>. If the anchor had been originally reified (instead of manually embeding it in the wiki text) a simple update of the [[Template:Anchor]] would've solved the problem.
+
The concept of ''anchor'' is essential to hypertext. The adaptation of using <tt>&lt;div id="original header"/&gt;</tt> (a ruthless hack) was done by [[User:Xavi|Xavi]] after discovering that the <tt>&lt;a&gt;</tt> is not allowed.  That solution broke down after an update of the wiki. The solution was to switch to an html compliant <tt>&lt;div id="original header"&gt;&lt;/div&gt;</tt>. If the anchor had been originally reified (instead of manually embedding it in the wiki text) a simple update of the [[Template:Anchor]] would've solved the problem.
  
So now, this is part of a (hopefully) better solution &mdash; suggestion by [[User:MitchellNCharity|MitchellNCharity]].
+
So now, this is part of a (hopefully) better solution &mdash; suggestion by [[olpc:User:MitchellNCharity|MitchellNCharity]].
 
</noinclude>
 
</noinclude>

Latest revision as of 11:37, 11 July 2009

This template creates an HTML anchor without creating a visible section header or a TOC entry.

Its main use is to allow the translation of links without interfering with the translation of content. The most usual 'problem' arising when translating is that some section titles are much less immutable than the original. For example, in the Human Interface Guidelines there's the concept of Home. The word itself may have several possible translations in a given language, and one may be preferred to others but may not have been the 'initial' choosing. In later revisions, the header could be changed for a better wording, but then all the links pointing to it would be broken. The solution is to use this template as the anchor for the original language header.

Example

In a page you are translating there's the following link to a section:

[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor#Home]]

You know the translated page will be named

Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx

You want to leave the link as

[[Human Interface Guidelines/The Laptop Experience/Zoom Metaphor/lang-xx#Home]]

so you don't have locate the translated section text and change the link to use it.

If the page you are linking to uses Template:Anchor then you can do this; the linking of translated pages (and their sections) can be done regardless of how the Home section header was translated — in spanish it could be translated as either Hogar or Casa—both actually linking to the anchor #Home and will both work.

It's also possible to link the translated section heading, for example#Hogar or #Casa—but in this case, one of them will not work.

Usage

ORIGINAL PAGE                TRANSLATED PAGE               REVISED TRANSLATION
                             {{Anchor|Home}}               {{Anchor|Home}}
== Home ==                   == Hogar ==                   == Casa ==

NOTE: the {{Anchor|original header}} must be in the previous line. Reason for this is that if placed below, when 'jumping' to it, the header will 'lost' (because it's above). The downside of this is that while editing a section, you can't manipulate it because it 'belongs' to the previous section.

Its use is discouraged outside the context of translating pages. If used outside that context, it is recommended to be used only within the same page (no inter-page linking using hidden anchors).

If the purpose is to avoid having a __TOC__ too deep, we should consider other solutions (heard about a {{TOClevel|n}} to limit the depth shown.

History & Credits

The concept of anchor is essential to hypertext. The adaptation of using <div id="original header"/> (a ruthless hack) was done by Xavi after discovering that the <a> is not allowed. That solution broke down after an update of the wiki. The solution was to switch to an html compliant <div id="original header"></div>. If the anchor had been originally reified (instead of manually embedding it in the wiki text) a simple update of the Template:Anchor would've solved the problem.

So now, this is part of a (hopefully) better solution — suggestion by MitchellNCharity.