Extension:Babel
Babel Release status: stable |
|||
---|---|---|---|
Implementation | Parser extension | ||
Description | Adds a parser function to inform other users about language proficiency and categorize users of the same levels and languages. | ||
Author(s) | Robert Leverington (RobertLtalk) | ||
Latest version | 1.8.2 (2014-01-05) | ||
MediaWiki | 1.20 or higher | ||
Database changes | No | ||
Composer | mediawiki/babel | ||
License | GPLv2+ | ||
Download | Included in Language Extension Bundle
CHANGELOG |
||
Example | Translatewiki.net | ||
|
|||
|
|||
Translate the Babel extension if it is available at translatewiki.net |
|||
Check usage and version matrix; code metrics | |||
Open tasks · Report a bug |
The Babel extension adds a parser function to replace the old Babel system that completely relied on templates. If an unrecognized language parameter is specified, it will see if there is an existing template with the name and include that.
On Wikimedia projects, the noun Babel (in reference to the Tower of Babel) refers to the texts on user pages aiding multilingual communication by making it easier to contact someone who speaks a certain language. The idea originated on the Wikimedia Commons and has also been implemented on many other wikis.
Download[edit | edit source]
The extension can be retrieved directly from Git [?]:
- Browse code
- Some extensions have tags for stable releases.
- Browse tags
- Select the tag
- Click "snapshot"
- 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).
- Browse branches
- Select a branch name
- Click "Continue"
Extract the snapshot and place it in the extensions/Babel/ 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/Babel.git
Installation[edit | edit source]
- Download the files from Git or download a snapshot. Choose the version that matches your version of MediaWiki.
- Create a directory
Babel
in your$IP/extensions
directory. - Extract the files to this
$IP/extensions/Babel
directory. - Add
require_once( "$IP/extensions/Babel/Babel.php" );
- The CSS is located in the file
resources/ext.babel.css
. You can change the style as desired by overriding them in the pageMediaWiki:Common.css
. Prior to version 1.19 you had to copy all the CSS toMediaWiki:Common.css
. - Installation can now be verified through Special:Version of your wiki.
If the CLDR extension is found language names are taken from that (where translations are unavailable), otherwise built in MediaWiki language names and English defaults are used.
Usage[edit | edit source]
Syntax for the #babel
parser function is as follows:
{{#babel: babelcode1 | babelcode2 | ... }}
Add one of the following codes for each language you speak or understand, separated by |
, where xx
is the MediaWiki language code, ISO 639-1 code, or ISO 639-3 code for the language. The general usage of each code level is as follows:
-
xx-0
- If you don't understand the language at all.
xx-1
- Basic ability - enough to understand written material or simple questions in this language.
xx-2
- Intermediate ability - enough for editing or discussions.
xx-3
- Advanced level - though you can write in this language with no problem, some small errors might occur.
xx-4
- "Near-native" level - although it's not your first language from birth, your ability is something like that of a native speaker.
xx-5
- Professional proficiency.
xx
orxx-N
- Native speakers who use a language every day and have a thorough grasp of it, including colloquialisms and idioms.
To include any other template, simply add the name of the template, e.g. add User from London
if you want to include Template:User from London
. A prefix or suffix may be added to template names (e.g. User
at the beginning) depending on the local configuration, this can be used to restrict the selection and reduce the length of parameters; for example from London
could include Template:User from London
if configured in such a way.
Configuration[edit | edit source]
Babel has six configuration variables which can be modified in LocalSettings.php
.
$wgBabelLanguageCodesCdb
- (string) the path of the language code database file, the default should suffice.
$wgBabelLanguageNamesCdb
- (string) the path of the language name database file, the default should suffice.
$wgBabelCategoryNames
- (array of string or boolean, indexed by the strings "1", "2", … "5", "N") where each entry is the name of a category for the skill level indicated by its index, possible variable elements are: %code% (language code), %wikiname% (the name of the language in the wiki's content language), and %nativename% (the name of the language in its language). To disable adding a category for a particular level, set the corresponding value to false.
- For example:
$wgBabelCategoryNames = array( '0' => 'User %code%-0', '1' => 'User %code%-1', '2' => 'User %code%-2', '3' => 'User %code%-3', '4' => 'User %code%-4', '5' => 'User %code%-5', 'N' => 'User %code%-N', );
- will use categories like "Category:User en-0" and "Category:User fr-N". The default is just "Category:Fr-N" and so on.
$wgBabelMainCategory
- (string) Name of the main (non-level) category for each language, to which all users of that language are added. Set to false to disable; defaults to format "Category:Fr". It accepts the same format as
$wgBabelCategoryNames
above. Example:- $wgBabelMainCategory = 'User %code%';
$wgBabelDefaultLevel
- (string) Default ability level to use when none is specified, should be an index from
$wgBabelCategoryNames
, that is one of the strings "1", "2", … "5", "N". Default is "N".
$wgBabelUseUserLanguage
- (boolean) Whether to use the user interface language for the header and footer message. If false (default), it will be in the page content language. This is because using the user interface language may fragment the parser cache.
Several customizations can also be made using MediaWiki namespace messages.
- MediaWiki:babel-template
- The format of template names when one is being included.
- MediaWiki:babel-portal
- The format of the target of the link from the language code.
- MediaWiki:Babel-autocreate-user
- Username to be used for autocreation of Babel related categories
- MediaWiki:babel-autocreate-text-levels
- Text to insert into auto-created categories for different language levels. You have to change this if you want them to be auto-categorized in the main category of the respective language (
$wgBabelMainCategory
). - MediaWiki:babel-autocreate-text-main
- Text to insert into auto-created categories for non-level categories. You have to change this if you want them to be auto-categorized in a parent category for all languages.
- MediaWiki:babel
- The header of the babel box
- MediaWiki:babel-url
- The pagename where information on the babel extension can be found
- MediaWiki:Babel-footer
- The footer of the babel box
- MediaWiki:babel-footer-url
- The page to link to in the footer of the babel box
Releases[edit | edit source]
nowrap! Version | Release date | Comments |
---|---|---|
0.1 | 2008-04-19 | Initial version. |
0.7 | 2008-04-26 | First beta. |
0.9 | 2008-05 | Second beta - still some known issues. |
1.0 | 2008-07-02 | Now stable. |
1.1.0 | 2009-02-22 | Rewrite language logic. |
1.2.0 | 2009-02-22 | Rewrite parameter parser (all MediaWiki supported languages now work), remove options parser (gender moved to core). |
1.2.1 | 2009-02-22 | Gender support for "babel" message. |
1.2.2 | 2009-02-22 | Change parser hook callback to be PHP 5.2.0 and lower compatible. |
1.2.3 | 2009-02-26 | Comment and whitespace alteration, fix possible exception by always returning null on an invalid language. |
1.3.0 | 2009-07-23 | Replace language code handling with CDB. |
1.4.0 | 2009-08-14 | New style magic words. |
1.4.1 | 2009-08-15 | Do not handle empty values. |
1.5.0 | 2011-01-20 | Updated language codes and names database, improve general code quality. |
1.6.0 | 2011-01-21 | Category name configuration moved from MediaWiki namespace messages to $wgBabelCategoryNames configuration variable. |
1.7.0 | 2011-01-24 | Flexibility and code quality improvements. Replaced $wgBabelUseLevelZeroCategory, $wgBabelUseSimpleCategories, and $wgBabelUseMainCategories with $wgBabelCategoryNames, $wgBabelMainCategory, and $wgBabelDefaultLevel. |
1.7.1 | 2011-07-14 | (bug 29663) Do nothing if the username of "babel-autocreate-user" is invalid. Do not create categories if the user is blocked. |
1.7.2 | 2011-08-09 | Use ResourceLoader for adding CSS. |
See also[edit | edit source]
- meta:Babel extension — discussion about whether it should be implemented on Wikimedia wikis
![]() |
This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |