Atajo :
WM:LS
This is Template:Stub without language selection.
This is Template:Stub with language selection (English and French).

Language select allows users to hide foreign languages on multilingual pages. This, for example, allows French readers to see only French text on multilingual pages (though they would still see Spanish on a Spanish-only page).

At right are two screenshots of Template:Stub without and with a language selection of English and French using the CSS method (see below).

Implementation

edit

There are two working implementations of language select. The preparation of a page for language selection is the same for both methods. The older CSS method allows multiple languages to be selected, most useful for multilingual users. However, it cannot recognize when no selected language is present, which results in no content being displayed. The newer JavaScript method detects the language of your browser automatically (you can configure it to ignore the browser setting), and does nothing if no selected language is present. However, it can only display one language at a time.

Identifying multilingual pages

edit

Pages that implement language selection include a notice linking back to this page using {{multilingual}}. There has been no discussion on the logo to use for this purpose; Localisation2.svg is currently used.

Delimiting languages

edit

Technical details

edit

A multilingual page is contained by the CSS class "multilingual", with text in every language contained within the class "lang-xx", where xx is a lowercase ISO 639 two-letter or three-letterlanguage code and the lang attribute. The lang attribute is contextually more correct, but the CSS required to hook into it is not supported by all browsers. If there is no two-letter code, the lowercase three-letter code is used. If you're translating existing messages and don't know what the language is, use the code "und".

An example page in English, Arabic, Old English, French, Latin, and Occitan:

<div class="multilingual">
<div class="lang-eng" lang="en">This text is Hunglish.</div>
<div class="lang-ar" lang="ar">هذا النّص عربي.</div>
<div class="lang-ang" lang="ang">Þis wordu is Englisc.</div>
<div class="lang-fr" lang="fr">Ce texte est Français.</div>
<div class="lang-la" lang="la">Haec verba latina sunt.</div>
<div class="lang-oc" lang="oc">Aqueste tèxt es en Occitan.</div>
</div>

Template

edit

The template {{ls}} simplifies the implementation of language select. For example, the following two lines are equivalent:

{{ls|en|This text is English.}}
<div class="lang-en" lang="en">'''English:''' This text is English.</div>

Usage

edit

Note that the two implementations conflict with each other, so only one should be used at a time.

The description below assumes you use the Monobook skin.

Cascading StyleSheets

edit

Add the following lines to your stylesheet, editing as appropriate for the languages you wish to view.

/* hide all languages */
.multilingual { display:none; }
/* unhide selected languages */
.multilingual .lang-en, .multilingual .lang-fr { display:block; }

If you are using a browser with good support for CSS (such as Mozilla Firefox or Opera) you should use this more contextually correct CSS.

.multilingual *[lang] {display:none;}
.multilingual *[lang|=en], .multilingual *[lang|=fr] {display:block;}

JavaScript

edit

The JavaScript method is activated by default on the Wikimedia MetaWiki. You can disable it by adding the following line to your script file.

ls_enable = false;

You can see an example of the JavaScript in action below. If language selection is disabled, all of the text will be displayed.

Afrikaans: Hierdie teks is in Afrikaans.
Bahasa Indonesia: Ini adalah teks dalam bahasa Indonesia.
Bahasa Melayu: Teks ini ditulis dalam Bahasa Melayu.
Boarisch: Des is a boarischa Text.
Беларуская: Гэты тэкст — на беларускай мове.
Беларуская (тарашкевіца): Гэты тэкст — на беларускай мове.
Brezhoneg : Brezhoneg eo an destenn-mañ.
Català : Aquest text és en català.
Dansk: Denne tekst er på dansk.
Deutsch: Dieser Text ist Deutsch.
English: This text is English.
Español : Ese texto está en español.
Esperanto: Ĉi tiu teksto estas en Esperanto.
Eesti: See tekst on eesti keeles.
Français : Ce texte est en français.
Frysk: Dizze tekst is yn it Frysk.
Galego: Este texto está en galego.
Hrvatski: Ovaj tekst je na hrvatskom jeziku.
Interlingua: Iste texto es in interlingua.
Italiano: Questo testo è in Italiano.
Kurdî: Ev xet bı Kurdi'yı.
Kurmanci: Ev xet bı Kurmanci'ye.
Latina: Haec nota latine scriptus est.
Lietuvių: Šis tekstas yra lietuviškas
Magyar: Ez a szöveg magyarul van
Nederlands: Deze tekst is in het Nederlands.
Norsk: Denne teksten er på norsk.
Occitan : Aqueste tèxt es en occitan.
ଓଡ଼ିଆ: ଏହି ଲେଖାଟି ଓଡ଼ିଆ ଭାଷାରେ ଲେଖାଯାଇଛି ।
Polski: Ten tekst jest po polsku.
Português : Este texto está em português.
Sardu: Custu testu est in sardu.
Suomi: Tämä teksti on suomeksi.
Svenska: Denna text är på svenska.
Türkçe: Bu tekst Türkçe'dir.
Ελληνικά: Αυτό το κείμενο είναι στα Ελληνικά
Български: Този текст е на български език.
Македонски: Ова е текст на македонски јазик.
Русский: Этот текст — на русском языке.
ქართული: ეს ტექსტი ქართულ ენაზეა.
தமிழ்: இது தமிழ் மொழி
日本語: この文章は日本語です。
한국어: 이 글은 한국어입니다.
中文: 这些文字是中文。 / 這些文字是中文。
ភាសាខ្មែរ៖ ឃ្លានេះជាភាសាខ្មែរ។
עברית: הטקסט הזה בעברית.
العربية: هذا النّص عربي.
فارسی: این متن فارسی است.
ئۇيغۇرچە / Uyghurche: بۇلار ئۇيغۇرچە

When specifying a language, use the code, not the full name.

You can view the JavaScript code at Commons:MediaWiki:Multilingual description.js.

Changelog

edit

The code is maintained in a private Subversion repository. I still have been unable to contact an MediaWiki developers on getting this code into Wikimedia's Subversion repository.

See also

edit
edit