Extensió:UniversalLanguageSelector

From MediaWiki.org
Jump to: navigation, search
This page is a translated version of the page Extension:UniversalLanguageSelector and the translation is 28% complete.

Outdated translations are marked like this.
Other languages:
العربية • ‎català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎हिन्दी • ‎magyar • ‎Bahasa Indonesia • ‎italiano • ‎日本語 • ‎occitan • ‎polski • ‎português • ‎português do Brasil • ‎русский • ‎sicilianu • ‎ไทย • ‎中文
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
UniversalLanguageSelector

Release status:Extension status stable

ULS-Display-Settings.png
ImplementationTemplate:Extension#type User interface, Skin, Beta Feature
DescriptionTemplate:Extension#description Eina que permet als usuaris seleccionar un idioma i configurar el seu suport d'una manera fàcil.
Author(s)Template:Extension#username Wikimedia Language team
MediaWikiTemplate:Extension#mediawiki 1.26+
Database changesTemplate:Extension#needs-updatephp No
ComposerComposer mediawiki/universal-language-selector
LicenseTemplate:Extension#license GNU General Public License 2.0 or later, The MIT License
Download

Inclosa en Language Extension Bundle

Hooks usedTemplate:Extension#hook
BeforePageDisplayManual:Hooks/BeforePageDisplay
PersonalUrlsManual:Hooks/PersonalUrls
ResourceLoaderTestModulesManual:Hooks/ResourceLoaderTestModules
ResourceLoaderGetConfigVarsManual:Hooks/ResourceLoaderGetConfigVars
MakeGlobalVariablesScriptManual:Hooks/MakeGlobalVariablesScript
UserGetLanguageObjectManual:Hooks/UserGetLanguageObject
SkinTemplateOutputPageBeforeExecManual:Hooks/SkinTemplateOutputPageBeforeExec
EnterMobileModeManual:Hooks/EnterMobileMode
GetPreferencesManual:Hooks/GetPreferences
GetBetaFeaturePreferencesManual:Hooks/GetBetaFeaturePreferences

No és compatible amb Internet Explorer 8 o inferior.

Translate the UniversalLanguageSelector extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

El Selector d'idiomes universal és una eina que permet als usuaris seleccionar un idioma i configurar el seu suport d'una manera fàcil. Quan s'usa, també incorpora la funcionalitat de les extensions WebFonts i Narayam (les quals han quedat en desús en favor del Selector d'idiomes universal). Vegeu Selector d'idiomes universal per a informació a fons i addicional.

Ús[edit]

L'objectiu principal és permetre als usuaris seleccionar un idioma i configurar el seu suport d'una manera fàcil.

L'extensió proporciona les següents característiques:

  1. Un sistema flexible i fàcil de seleccionar un idioma en un gran conjunt d'idiomes.
    1. La selecció es pot basar en la navegació segons la regió geogràfica.
    2. La cerca es pot basar en el codi de llenguatge ISO, el nom de l'idioma escrit en la interfície de l'usuari actual o en el seu propi guió(autònim)
    3. Cerca directa de l'idioma o pels noms dels idiomes utilitzant qualsevol script
    4. Autocompletat dels noms dels idiomes
    5. Correcció automàtica d'errors d'ortografia en les cadenes de cerca
    6. Suggeriments d'idiomes basat en la geolocalització IP
    7. Selecció d'idiomes basat en el sistema operatiu i en el navegador de l'usuari
  2. Mètodes d'entrada de caràcters (per exemple hi ha un mètode per l'esperanto que permet, entre altres convertir CH en Ĉ)
    Consulteu Help:Extension:UniversalLanguageSelector/Input methods per obtenir instruccions completes.
    1. Una col·lecció de mètodes d'entrada fàcilment seleccionables, fàcilment disponible en tots els camps editables
    2. Proporciona un gran conjunt de mètodes d'entrada per a la gran varietat d'idiomes
    3. Preferències de mètode d'entrada per idioma
  3. Tipus de lletra del web
    1. Una gran col·lecció de fonts per triar per a cada idioma que s'utilitzarà com a tipus de lletra incorporat de la pàgina
    2. Preferències del tipus de lletra per idioma
Selector d'idiomes universal amb GeoIP basat suggeriment d'idioma per a un usuari des d'Espanya
Language settings allow a registered user accessing English Wikipedia to change the UI to his native language.
A Bengali user is able to read content from the Bengali Wikipedia despite the lack of fonts in his computer. Web fonts are provided automatically for non-latin scripts for which an open source font is available. The user can decide to use their system fonts on a per language basis.
A Hindi speaker without a Hindi keyboard configures input methods so that he can type in his language.
When searching a user can switch between English and Hindi.

Adding fonts[edit]

Supporting more languages is only a matter of including the proper fonts in the code. However, please note that we will add support only for freely licensed fonts, for example fonts licensed under GNU GPL, SIL OFL, etc. An example directory of such free fonts is Google Fonts [1] (not yet fully examined/exploited by the authors of this extension); see also the Open Font Library.

First of all, you need to find or produce such a free font (this is the most important part and you have to do it yourself); then, it has to be converted to the required formats, which are eot, ttf, woff; finally, you can file a request in Phabricator for the font to be added to the extension.

#Preparing webfonts below explains how to convert the fonts: basic knowledge about GNU/Linux based operating system is required; if you have difficulty in doing this, you can skip this step and ask someone else to do it for you on the same Phabricator request (of course this will slow down the process).

Preparing webfonts[edit]

Sfntly is required for creating web fonts (command line only).

Once installed, following commands can be used.

Creating .woff:

java -jar /path/to/sfnttool.jar -w xyz.ttf xyz.woff

Creating .woff2:

Use https://github.com/google/woff2 to generate woff2 from ttf. This will produce a compressed woff2 file. Modern browsers support this format.

Create a font.ini file. Here's an example:

[AbyssinicaSIL]
languages=am*, ti*
version=1.200
license=OFL 1.1
licensefile=OFL.txt
url=http://scripts.sil.org/AbyssinicaSIL

An asterisk (*) after a language code means that this font will be the default font for that language. If you just want the option to use this font for that language, don't use the asterisk.

After creating the files, do the following:

  1. Create a directory for the font under data/fontrepo/fonts.
  2. Put the ttf, woff, eot and font.ini files in that directory and add them to the source repository (git add).
  3. Go to data/fontrepo/scripts and run php compile.php.
  4. Commit the changes to the repository (git commit -a) and submit them according to the Git workflow.

Adding support for a new key mapping (input method)[edit]

Follow the instructions on the jquery.ime github wiki, but file requests in the Wikimedia-extensions-UniversalLanguageSelector Phabricator product.

Descàrrega[edit]

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/UniversalLanguageSelector/ directory of your MediaWiki installation.

If you are familiar with git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UniversalLanguageSelector.git

Instal·lació[edit]

  • Download and place the file(s) in a directory called UniversalLanguageSelector in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'UniversalLanguageSelector' );
    
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Actualització de LanguageNameIndex[edit]

Per realitzar una recerca d'idiomes, buscant per un autònims, les dades de l'idioma necessiten ser omplertes. El Selector d'idiomes universal ve amb un índex de noms d'idiomes pre-omplerts (data/langnames.ser). En cas que vulgueu actualitzar-les, instal·leu Extensió:CLDR i actualitzeu les dades amb la següent ordre.

php UniversalLanguageSelector/data/LanguageNameIndexer.php

i verifiqueu que el fitxer langnames.ser s'ha generat en la carpeta UniversalLanguageSelector/data/.

Configuració[edit]

The following variables are created automatically during initialization and can be used from JavaScript using mw.config.get( NAME ):

  • wgULSLanguages - an associative array where the keys are language codes and the values are language names in English.
  • wgULSAcceptLanguageList - an array of language codes from the user's Accept-Language value. These are the languages selected in the user's browser preferences.

For serving fonts, you might want to add the following mime types to your webserver if not already there. This guide might help.

application/x-font-woff .woff
application/vnd.ms-fontobject .eot
application/x-font-ttf .ttf

The following variables can also be configured:

  • $wgULSGeoService- ULS can use geolocation services to suggest languages based on the country the user is visiting from. Setting this to false will prevent builtin geolocation from being used. You can provide your own geolocation by setting window.Geo to object which has key 'country_code' or 'country'. If set to true, it will query Wikimedia's geoip service. The service should return jsonp that uses the supplied callback parameter. Defaults to http://freegeoip.net/json/ and expects the same format.
  • $wgULSEnable - Enable language selection, compact language links, input methods and webfonts for everyone, unless the behavior is overridden by the configuration variables below. Even if false the classes and resource loader modules are registered for the use of other extensions. Language changing via cookie or setlang query parameter is not possible.
  • $wgULSAnonCanChangeLanguage - Allow anonymous users to change language with cookie and setlang query param. Do not use if you are caching anonymous page views without taking cookies into account. Does not have any effect if either of $wgULSEnable or $wgULSEnableAnon is set to false.
  • $wgULSIMEEnabled - Disable the input methods feature for all users by default. Can still be enabled manually by the user.
  • $wgULSPosition - The location and the form of the language selection trigger. The possible values are: personal: as a link near the username or the log in link in the personal toolbar (default). interlanguage: as an icon near the header of the list of interlanguage links in the sidebar.
  • $wgULSNoImeSelectors - Array of jQuery selectors of elements on which IME must not be enabled. eg: array( '#wpCaptchaWord' );

Position of ULS trigger[edit]

  • $wgULSPosition - The location and the form of the language selection trigger. The possible values are: personal: as a link near the username or the log in link in the personal toolbar (default). interlanguage: as an icon near the header of the list of interlanguage links in the sidebar.

It is also possible to have ULS trigger anywhere in the screen. An element with uls-settings-trigger will act as a ULS trigger.

Overriding default fonts[edit]

ULS has a large font repository to serve as webfonts. Sometimes there are multiple fonts for a language and there is a default font for each language/script. The order of fonts or default font can be overridden as follows using global scripts (MediaWiki:Common.js) or personal scripts (Special:MyPage/common.js):

$.webfonts.repository.languages.languageCode = ["system", "FontA", "FontB"];

Here, languageCode should be a valid language code(eg: en, hi, nl). FontA and FontB are fonts available in font repository. In the above example for languageCode, we set a font available in local computer as default font. ie No default webfont.

Caching configuration[edit]

To ensure that the web fonts files are cached on the clients' machines, font file types must be added to the web server configuration. In Apache2 this consists of:

  • Adding font file extensions to the FileTimes regex at FilesMatch for the relevant directory, example:

<FilesMatch "\.(gif|jpe?g|png|css|js|woff|svg|eot|ttf)$">

  • Adding ExpiresByType values to the relevant MIME types, similarly to image MIME types.
    • Note that there's no standard MIME type for TTF. application/x-font-ttf is used for Wikimedia.
  • Adding the MIME types:
AddType application/x-woff .woff
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf

For a full example see the caching configuration update done for the Wikimedia cluster.

Traducció de les pàgines[edit]

UniversalLanguageSelector is one of the dependencies of the Translate extension, which uses it for several language selection features. One of it is the MyLanguage system for links, which depends on the interface language of the user, but more can be configured: see Page translation feature.

Using Webfonts[edit]

User can choose webfonts for a language from the Language settings -> Display settings. By default, the first font in that menu will be applied to the wiki. A user can change the font and it will be remembered across the pages. Optionally user can disable the font embedding too by selecting system font.

If the font is available in user's local system, font will not be downloaded from the mediawiki server. It will be taken from the user's computer. Otherwise, font will be downloaded from the server only once. ie when the user selects the font first time. Next time onwards, font will be taken from the local cache.

Alternate ways to load fonts[edit]

By specifying font-family[edit]

Inside the wiki text <span style="font-family:'YourFontName';">YourText</span>, webfonts extension will check whether the font is available with the extension, if so it will download it to the client. So the reader will not face any difficulty in reading the text even if the font specified is not available in their computer.

By specifying language[edit]

Inside the wiki text <span lang="my">YourText</span>, webfonts extension will check whether any font is available for the given language with the extension, if so it will download it to the client. So the reader will not face any difficulty in reading the text even if the font specified is not available in their computer. If there are multiple fonts for the language, the default font will be used. If default font is not preferred, use the font-family approach to specify the font. If the tag has both lang and font-family definitions, font-family get precedence.

Exemple:

<span lang=sux>𒄖𒉈𒅁𒌨𒅎</span>

gives the text rendered in Cuneiform using Akkadian font

𒄖𒉈𒅁𒌨𒅎

Vegeu també[edit]