Template:Glossary

<%
// Inserts a link to a term's entry in our glossary.
// Appropriate styling is applied.
//
// Parameters:
//
//  $0 - Term name
//  $1 - name to display (optional)
//  $2 - Remove custom style on links; boolean (optional)

var str = $1 || $0;
var css = !$2 ? "glossaryLink" : "";

// Terme location
var URL_EN = "/en-US/docs/Glossary/";
var URL    = mdn.localString({
    "en-US": URL_EN,
    "de"   : "/de/docs/Glossary/",
    "fr"   : "/fr/docs/Glossaire/",
    "pt-BR": "/pt-BR/docs/Glossario/",
    "ru"   : "/ru/docs/Словарь/"
});

URL_EN += $0.replace(/\s+/g,'_');
URL    += $0.replace(/\s+/g,'_');

var page    = wiki.getPage(URL);
var summary = mdn.localString({
    "en-US": "The definition of that term (" + str + ") has not been written yet; please consider contributing it!",
    "de"   : "Die Definition dieses Ausdrucks (" + str + ") wurde noch nicht geschrieben; bitte hilf mit und trage sie bei!",
    "fr"   : "La définition de ce terme ("+ str + ") n'a pas encore été rédigée. Nous serions heureux de vous voir l'écrire&nbsp;!",
    "ru"   : "Определение термина «" + str + "» ещё не написано; может быть, вы напишете?"
});

if (page && page.summary) {
    summary = str + ': ' + mdn.escapeQuotes(page.summary);
} else if (env.locale !== "en-US") {
    page = wiki.getPage(URL_EN);
    URL  = URL_EN.replace('en-US', env.locale);
    if (page && page.translations && page.translations.length > 0) {
        page.translations.forEach(function (obj) {
            if (obj.locale === env.locale) {
                URL  = obj.url;
                page = wiki.getPage(URL);
                if (page && page.summary) {
                    summary = str + ': ' + mdn.escapeQuotes(page.summary);
                }
            }
        })
    }
}
%><a href="<%- URL %>" title="<%-summary%>" class="<%-css%>"><%= str %></a>
Search for pages that use Template:Glossary to see example use cases and how many pages use this macro.

Document Tags and Contributors

Tags: 
Last updated by: Sheppy,