Meta:Language select/pt
Seleção do idioma, permite que os utilizadores ocultem os idiomas estrangeiros nas páginas multilingue. Isto, por exemplo, permite que os leitores franceses vejam o texto apenas em francês nas páginas multilingue.
Notas :
- The Language select functionality described in this page should be used only when there are very few translations, and for translating a few sentences. The Language select functionality is only intended for pages (like generated activity reports, or user pages) that will be rarely translated, or for documenting category pages (when the creation of separate subcategories, for storing collections of translated pages per language, or is not desirable, or not possible for describing images).
- Pages that are designed to be fully translated into multiple single-languages with subpages (See Meta:Translation for details) should preferably not use Language select, but a language bar to allow navigation between these pages.
- As well, generic message boxes informing about the status of a page should be transcluded from templates that avoid using Language Select, but use Language Switching (see Template:LangSwitch) or the newer Translate extension, in order to display the user language directly.
At right are two screenshots of Template:Stub (which earlier used the Language Select mechanism) without and with a language selection of English and French using the CSS method (see below) Now this template is autotranslated to the user language and will then no longer display all translations.
Implementação
editThere 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.
Identificar as páginas multilingue
editPages 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.
-
Proposta de Zscout370
-
Proposta de Pathoschild
-
Proposta de "Globe of letters"
Delimitar os idiomas
editDetalhes técnicos
editA multilingual page is contained by the CSS class "multilingual", with text in every language contained within HTML elements tagged with the class="lang-xx"
attribute, where xx is a lowercase BCP 47 language code (generally two or three letters from ISO 639, possibly followed by variant sufixes; if there is no two-letter code, the lowercase three-letter code is used.) and the HTML lang
attribute. The lang
attribute is contextually more correct than the class, but the CSS required to hook into it is not supported by all browsers. If you're translating existing messages and don't know what the language is, use the code "und".
An example page in Old English, English, French, Ukrainian, Latin, Occitan, Romanian, Kiswahili, Arabic, Persian, and Uighur:
<div class="multilingual">
<div class="lang-ang" lang="ang">Þis wordu is Englisc.</div>
<div class="lang-en" lang="en">This text is English.</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-pa" lang="pa">ਇਹ ਟੈਕਸਟ ਪੰਜਾਬੀ ਵਿੱਚ ਹੈ।</div>
<div class="lang-oc" lang="oc">Aqueste tèxt es en Occitan.</div>
<div class="lang-pt" lang="pt">Este texto está em português.</div>
<div class="lang-ro" lang="ro">Acest text este în română.</div>
<div class="lang-sw" lang="sw">Maelezo haya ni ya Kiswahili.</div>
<div class="lang-ar" lang="ar">هذا النّص عربي.</div>
<div class="lang-fa" lang="fa">اين نوشته فارسي است.</div>
<div class="lang-ug" lang="ug">بۇ ئۇيغۇرچە</div>
</div>
Note that for correct visual vsual ordering of the rendered native language names, the list has to be sorted manually on the page itself (and not sorted by language code), otherwise the relative order is kept and may finally be arbitrary and difficult to scan for readers to find their desired language.
Modelos
editThe {{Ls}}
template simplifies the implementation of language select. For example, the following two lines are equivalent (however the template also provides some other useful formatting options such as displaying a tooltip showing the language name in the current user language, and the associated language code, or coloring fuzzy translations needing updates):
{{Ls|en|This text is English.}}
<div class="lang-en" lang="en" dir="ltr">'''English:''' This text is English.</div>
This {{Ls}}
template may be used multiple times within the multilingual section, including for the same language. The relative order of inclusion of Ls templates in the section is also kept, but in many cases you'll want to order languages in a consistent order. The {{LangSelect}}
will simplify this (but will accept only one occurrence of each language).
Note that, currently, the language selection form with buttons is generated by Javascript below multilingual sections below each multilingual section in the current page, and an additional language selection box is also displayed at top of page (it displays a list of all language codes used in multilingual sections any where on the page, still without sorting them for easier selection). This can be customized with CSS (see below).
Compare how translations are mixed and difficult to find (notably when script directions are alternating) when they are initially sorted by language code (for easier editing and maintenance) when using multiple inclusions of {{Ls}}
, and how {{LangSelect}}
orders them visually by script (scripts being ordered by direction and type) and then alphabetically by language name, grouping all right-to-left languages separately from left-ro-right languages:
Wiki code | Rendering |
---|---|
<div class="multilingual">
{{Ls|ar|هذا النص باللغة العربية.}}
{{Ls|da|Denne tekst er på dansk.}}
{{Ls|en|This text is English.}}
{{Ls|fa|این متن به زبان فارسی است.}}
{{Ls|fi|Tämä teksti on suomeksi.}}
{{Ls|fr|Ce texte est en français.}}
{{Ls|frc|update=en|Ce texte devrait être en français cajun.}}
{{Ls|he|טקסט כתוב בעברית.}}
{{Ls|hi|यह पाठ हिन्दी में है।}}
{{Ls|pa|ਇਹ ਟੈਕਸਟ ਪੰਜਾਬੀ ਵਿੱਚ ਹੈ।}}
{{Ls|pt|Este texto está em português.}}
{{Ls|ru|Этот текст на русском языке.}}
{{Ls|sv|Denna text är på svenska.}}
{{Ls|th|ข้อความนี้อยู่ในไทย.}}
{{Ls|ur|یہ متن اردو ہے.}}
{{Ls|zh|इस पाठ में चीनी है.}}
{{Ls|zu|Lo mbhalo Zulu.}}
</div>
|
العربية: هذا النص باللغة العربية.
Dansk: Denne tekst er på dansk.
English: This text is English.
فارسی: این متن به زبان فارسی است.
Suomi: Tämä teksti on suomeksi.
Français : Ce texte est en français.
Français cadien: Ce texte devrait être en français cajun. [update needed: en]
עברית: טקסט כתוב בעברית.
हिन्दी: यह पाठ हिन्दी में है।
मराठी: हा मजकूर मराठीत आहे.
ਪੰਜਾਬੀ: ਇਹ ਟੈਕਸਟ ਪੰਜਾਬੀ ਵਿੱਚ ਹੈ।
Português : Este texto está em português.
Русский: Этот текст на русском языке.
Svenska: Denna text är på svenska.
ไทย: ข้อความนี้อยู่ในไทย.
اردو: یہ متن اردو ہے.
中文: इस पाठ में चीनी है.
IsiZulu: Lo mbhalo Zulu.
|
{{LangSelect | update = en
| ar = هذا النص باللغة العربية.
| da = Denne tekst er på dansk.
| en = This text is English.
| fa = این متن به زبان فارسی است.
| fi = Tämä teksti on suomeksi.
| fr = Ce texte est en français.
| frc:FUZZY = Ce texte devrait être en français cajun.
| he = טקסט כתוב בעברית.
| hi = यह पाठ हिन्दी में है।
| mr = हा मजकूर मराठीत आहे.
| pa = ਇਹ ਟੈਕਸਟ ਪੰਜਾਬੀ ਵਿੱਚ ਹੈ।
| pt = Este texto está em português.
| ru = Этот текст на русском языке.
| sv = Denna text är på svenska.
| th = ข้อความนี้อยู่ในไทย.
| ur = یہ متن اردو ہے.
| zh = इस पाठ में चीनी है.
| zu = Lo mbhalo Zulu.
}}
|
Dansk: Denne tekst er på dansk. English: This text is English. Français : Ce texte est en français. Français cadien: Ce texte devrait être en français cajun. [update needed: en] IsiZulu: Lo mbhalo Zulu. Português : Este texto está em português. Suomi: Tämä teksti on suomeksi. Svenska: Denna text är på svenska. Русский: Этот текст на русском языке. हिन्दी: यह पाठ हिन्दी में है। ਪੰਜਾਬੀ: ਇਹ ਟੈਕਸਟ ਪੰਜਾਬੀ ਵਿੱਚ ਹੈ। ไทย: ข้อความนี้อยู่ในไทย. 中文: इस पाठ में चीनी है. עברית: טקסט כתוב בעברית. اردو: یہ متن اردو ہے. العربية: هذا النص باللغة العربية. فارسی: این متن به زبان فارسی است. |
The template {{LangSwitch}}
is similar to {{LangSelect}}
, except that it will display only one language (a specified language, or the language of the content of the current page).
Utilização
editNote 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.
Folhas de Estilo em Cascata
editAdd the following lines to your stylesheet, editing as appropriate for the languages you wish to view:
/* hide all translations (avoid this, it may hide as well the original source language) */
.multilingual { display:none; }
/* unhide only the 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; }
If you want to hide only the language selection forms below multilingual sections (and use only the selector box added at top of pages), you may also use this CSS code:
/* hide the language selection form below multilingual sections */
.multilingual>form.lang_info { display:none; }
If instead you want to hide only the language selector box at top of pages (and keep the language selection forms below multilingual sections), you may also use this CSS code:
/* hide the language selector box at top of multilingual pages */
.langselectorcontainer { display:none; }
JavaScript
editThe 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.
When specifying a language, use the code, not the full name.
You can view the JavaScript code at Commons:MediaWiki:Multilingual description.js.
Registo de Alterações
editThe 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 1999 — --DieBuche 10:34, 7 November 2010 (UTC)
- Revision 1358 — Edward Z. Yang(Talk) 15:36, 19 February 2007 (UTC)
- 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.
- If no cookie is present, code will sniff
- Revision 1133 — Edward Z. Yang(Talk) 22:33, 2 September 2006 (UTC)
- 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