Meta:Language select/he

From Meta, a Wikimedia project coordination wiki
קיצור דרך:
WM:LS
תבנית קצרמר ללא בחירת שפה.
תבנית קצרמר עם בחירת שפה (צרפתית ואנגלית)

בחירת שפה (Language select) מאפשר למשתמשים להסתיר שפות זרות בדפים רב לשוניים. כך יכול למשל קורא עברי לראות רק טקסט עברי בדפים רב לשוניים (אבל בדפים שכתובים בספרדית בלבד, עדיין יראה הקורא את הדף בספרדית).

משמאל מופיעות שתי תמונות של צילומי מסך של תבנית:קצרמר עם וללא בחירת שפה עם אנגלית וצרפתית בשיטה הCSS (ראו להלן).

מימוש[edit]

יש שני מימושים עובדים של בחירת שפה. הכנת הדף לבחירת שפה נעשית בשתי הצורות באופן זהה. השיטה הישנה היא שיטת הCSS המאפשרת לבחור מספר שפות, והיא שימושית במיוחד עבור משתמשים הדוברים מספר שפות. עם זאת, השיטה מוגבלת ולא יכולה לזהות כאשר אין את השפה הנבחרת, והתוצאה היא שלא מופיע תוכן. הגרסה החדשה יותר מבוססת על JavaScript מזהה את השפה של הדפדפן אוטומטית (ניתן לקנפג כך שיתעלם מהדפדפן), ולא עושה דבר אם לא נבחרה שפה. חסרונה הוא שהיא מציגה שפה אחת בלבד כל פעם.

זיהוי דפים רב לשוניים[edit]

דפים הממשים בחירת שפה מצביעים לדף זהבאמצעות {{תבנית multilingual}}.הלוגו המייצג זאת כיום הוא ; Localisation2.svg.

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-en" lang="en">This text is English.</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">'''spanish:''' This text is spanish.</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.
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.
Esperanto: Ĉi tiu teksto estas en Esperanto.
Español : Ese texto está en español.
Eesti: See tekst on eesti keeles.
العربية: هذا النّص عربي.
فارسی: این متن فارسی است.
Suomi: Tämä teksti on suomeksi.
Français : Ce texte est 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.
Bahasa Indonesia: Ini adalah teks dalam bahasa Indonesia.
Italiano: Questo testo è in Italiano.
日本語: この文章は日本語です。
ქართული: ეს ტექსტი ქართულ ენაზეა.
한국어: 이 글은 한국어입니다.
ភាសាខ្មែរ៖ ឃ្លានេះជាភាសាខ្មែរ។
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.
தமிழ்: இது தமிழ் மொழி
Türkçe: Bu tekst Türkçe'dir.
ئۇيغۇرچە / Uyghurche: بۇلار ئۇيغۇرچە
中文: 这些文字是中文。 / 這些文字是中文。
Bahasa Melayu: Teks ini ditulis dalam Bahasa Melayu.

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

You can view the JavaScript code at MediaWiki:Monobook.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.

  • Revision 1358 — Edward Z. Yang(Talk) 15:36, 19 February 2007 (UTC)[reply]
    • If no cookie is present, code will sniff wgUserLanguage global variable
    • If language is set to blank, delete the cookie and switch to auto-detection.
  • Revision 1133 — Edward Z. Yang(Talk) 22:33, 2 September 2006 (UTC)[reply]
    • Tweaked Show all behavior to be more user-friendly: instead of overwriting your cookie, it only temporarily shows all the language strings. You can switch back by pressing Select
    • Renamed Save to Select
    • Styled the Select button to be bold.
    • Factored out language strings

See also[edit]

External links[edit]