diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-28 09:50:25 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-28 09:50:25 -0500 |
commit | 5744df39e15f85c6cc8a9faf8924d77e76d2b216 (patch) | |
tree | a8c8dd40a94d1fa0d5377566aa5548ae55a163da /resources/mediawiki.language | |
parent | 4bb2aeca1d198391ca856aa16c40b8559c68daec (diff) | |
parent | 224b22a051051f6c2e494c3a2fb4adb42898e2d1 (diff) |
Merge branch 'archwiki'
Conflicts:
extensions/FluxBBAuthPlugin.php
extensions/SyntaxHighlight_GeSHi/README
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
extensions/SyntaxHighlight_GeSHi/geshi/docs/CHANGES
extensions/SyntaxHighlight_GeSHi/geshi/docs/THANKS
extensions/SyntaxHighlight_GeSHi/geshi/docs/TODO
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constant.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constructor.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Destructor.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Function.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Global.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/I.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Index.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/L.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lminus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lplus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Method.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateVariable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticVariable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/T.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tminus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tplus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Variable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/blank.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/class_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/file.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/function_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button_disabled.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button_disabled.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/private_class_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/up_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/4cs.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502acme.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502kickass.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502tasm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/68000devpac.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/abap.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript3.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ada.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/algol68.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/apache.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/applescript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/apt_sources.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/asm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/asp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoconf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autohotkey.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoit.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/avisynth.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/awk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bascomavr.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bash.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/basic4gl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bibtex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/blitzbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bnf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/boo.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_loadrunner.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_mac.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/caddcl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cadlisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfdg.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/chaiscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cil.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/clojure.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cmake.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cobol.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/coffeescript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp-qt.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/csharp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/css.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cuesheet.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/d.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dcs.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/delphi.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/diff.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/div.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dos.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dot.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/e.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ecmascript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/eiffel.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/email.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/epc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/erlang.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/euphoria.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/f1.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/falcon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fo.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fortran.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/freebasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fsharp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gambas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gdb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/genero.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/genie.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gettext.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/glsl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gnuplot.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/go.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/groovy.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gwbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/hicest.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/hq9plus.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/html4strict.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/html5.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/icon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/idl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ini.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/inno.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/intercal.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/io.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/j.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/java.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/java5.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/javascript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/jquery.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/kixtart.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonec.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonecpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/latex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/llvm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/locobasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/logtalk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lolcode.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusformulas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lsl2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lua.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/m68k.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/magiksf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/make.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mapbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/matlab.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mirc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mmix.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula3.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mpasm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mxml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mysql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/newlisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/nsis.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oberon2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/objc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/objeck.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml-brief.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oobas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle11.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle8.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oxygene.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oz.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pascal.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pcre.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/per.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl6.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pic16.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pike.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pixelbender.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pli.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/plsql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/postgresql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/povray.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/powerbuilder.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/powershell.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/proftpd.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/progress.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/prolog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/properties.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/providex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/purebasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pycon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/python.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/q.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/qbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rails.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rebol.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/reg.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/robots.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rpmspec.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rsplus.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ruby.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scala.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scheme.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scilab.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sdlbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/smalltalk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/smarty.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/systemverilog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/tcl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/teraterm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/text.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/thinbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/tsql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/typoscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/unicon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/uscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vala.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vbnet.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/verilog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vhdl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vim.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualfoxpro.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualprolog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/whitespace.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/whois.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/winbatch.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xorg_conf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/yaml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/z80.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/zxbasic.php
Diffstat (limited to 'resources/mediawiki.language')
18 files changed, 453 insertions, 136 deletions
diff --git a/resources/mediawiki.language/languages/bs.js b/resources/mediawiki.language/languages/bs.js index c0c77aaf..65eb5a6d 100644 --- a/resources/mediawiki.language/languages/bs.js +++ b/resources/mediawiki.language/languages/bs.js @@ -2,10 +2,10 @@ * Bosnian (bosanski) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'bs', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'bs', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/mediawiki.language/languages/dsb.js b/resources/mediawiki.language/languages/dsb.js index a42a8f7f..b2c9c081 100644 --- a/resources/mediawiki.language/languages/dsb.js +++ b/resources/mediawiki.language/languages/dsb.js @@ -2,10 +2,10 @@ * Lower Sorbian (Dolnoserbski) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'dsb', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'dsb', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/mediawiki.language/languages/fi.js b/resources/mediawiki.language/languages/fi.js index 374698dc..61c6c104 100644 --- a/resources/mediawiki.language/languages/fi.js +++ b/resources/mediawiki.language/languages/fi.js @@ -3,21 +3,24 @@ * @author Santhosh Thottingal */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'fi', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms, aou, origWord; + + grammarForms = mediaWiki.language.getData( 'fi', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } // vowel harmony flag - var aou = word.match( /[aou][^äöy]*$/i ); - var origWord = word; + aou = word.match( /[aou][^äöy]*$/i ); + origWord = word; if ( word.match( /wiki$/i ) ) { aou = false; } //append i after final consonant - if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) + if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) { word += 'i'; + } switch ( form ) { case 'genitive': diff --git a/resources/mediawiki.language/languages/ga.js b/resources/mediawiki.language/languages/ga.js index a27b489d..c13e8321 100644 --- a/resources/mediawiki.language/languages/ga.js +++ b/resources/mediawiki.language/languages/ga.js @@ -2,10 +2,11 @@ * Irish (Gaeilge) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'ga', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + /*jshint onecase:true */ + var grammarForms = mediaWiki.language.getData( 'ga', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'ainmlae': diff --git a/resources/mediawiki.language/languages/he.js b/resources/mediawiki.language/languages/he.js index d35f77ed..13d457b2 100644 --- a/resources/mediawiki.language/languages/he.js +++ b/resources/mediawiki.language/languages/he.js @@ -3,26 +3,26 @@ */ mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'he', 'grammarForms' ); + var grammarForms = mediaWiki.language.getData( 'he', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'prefixed': case 'תחילית': // the same word in Hebrew // Duplicate prefixed "Waw", but only if it's not already double - if ( word.substr( 0, 1 ) === "ו" && word.substr( 0, 2 ) !== "וו" ) { - word = "ו" + word; + if ( word.substr( 0, 1 ) === 'ו' && word.substr( 0, 2 ) !== 'וו' ) { + word = 'ו' + word; } // Remove the "He" if prefixed - if ( word.substr( 0, 1 ) === "ה" ) { + if ( word.substr( 0, 1 ) === 'ה' ) { word = word.substr( 1, word.length ); } // Add a hyphen (maqaf) before numbers and non-Hebrew letters - if ( word.substr( 0, 1 ) < "א" || word.substr( 0, 1 ) > "ת" ) { - word = "־" + word; + if ( word.substr( 0, 1 ) < 'א' || word.substr( 0, 1 ) > 'ת' ) { + word = '־' + word; } } return word; diff --git a/resources/mediawiki.language/languages/hsb.js b/resources/mediawiki.language/languages/hsb.js index 211d67b5..77dca75e 100644 --- a/resources/mediawiki.language/languages/hsb.js +++ b/resources/mediawiki.language/languages/hsb.js @@ -2,10 +2,10 @@ * Upper Sorbian (Hornjoserbsce) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms =mw.language.getData( 'hsb', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'hsb', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'instrumental': // instrumental diff --git a/resources/mediawiki.language/languages/hu.js b/resources/mediawiki.language/languages/hu.js index eb3f1f3a..23b0c125 100644 --- a/resources/mediawiki.language/languages/hu.js +++ b/resources/mediawiki.language/languages/hu.js @@ -3,10 +3,10 @@ * @author Santhosh Thottingal */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'hu', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'hu', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'rol': diff --git a/resources/mediawiki.language/languages/hy.js b/resources/mediawiki.language/languages/hy.js index 215e7504..65081bdd 100644 --- a/resources/mediawiki.language/languages/hy.js +++ b/resources/mediawiki.language/languages/hy.js @@ -2,10 +2,11 @@ * Armenian (Հայերեն) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'hy', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + /*jshint onecase:true */ + var grammarForms = mediaWiki.language.getData( 'hy', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } // These rules are not perfect, but they are currently only used for site names so it doesn't @@ -13,14 +14,15 @@ mediaWiki.language.convertGrammar = function( word, form ) { switch ( form ) { case 'genitive': // սեռական հոլով - if ( word.substr( -1 ) === 'ա' ) + if ( word.substr( -1 ) === 'ա' ) { word = word.substr( 0, word.length -1 ) + 'այի'; - else if ( word.substr( -1 ) === 'ո' ) + } else if ( word.substr( -1 ) === 'ո' ) { word = word.substr( 0, word.length - 1 ) + 'ոյի'; - else if ( word.substr( -4 ) === 'գիրք' ) + } else if ( word.substr( -4 ) === 'գիրք' ) { word = word.substr( 0, word.length - 4 ) + 'գրքի'; - else + } else { word = word + 'ի'; + } break; } return word; diff --git a/resources/mediawiki.language/languages/la.js b/resources/mediawiki.language/languages/la.js index 313bb1c2..27110241 100644 --- a/resources/mediawiki.language/languages/la.js +++ b/resources/mediawiki.language/languages/la.js @@ -3,10 +3,10 @@ * @author Santhosh Thottingal */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'la', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'la', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'genitive': diff --git a/resources/mediawiki.language/languages/os.js b/resources/mediawiki.language/languages/os.js index 431e38c8..682b3903 100644 --- a/resources/mediawiki.language/languages/os.js +++ b/resources/mediawiki.language/languages/os.js @@ -4,23 +4,24 @@ */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'os', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'os', 'grammarForms' ), + // Ending for allative case + endAllative = 'мæ', + // Variable for 'j' beetwen vowels + jot = '', + // Variable for "-" for not Ossetic words + hyphen = '', + // Variable for ending + ending = ''; + if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } - // Ending for allative case - var end_allative = 'мæ'; - // Variable for 'j' beetwen vowels - var jot = ''; - // Variable for "-" for not Ossetic words - var hyphen = ''; - // Variable for ending - var ending = ''; // Checking if the $word is in plural form if ( word.match( /тæ$/i ) ) { word = word.substring( 0, word.length - 1 ); - end_allative = 'æм'; + endAllative = 'æм'; } // Works if word is in singular form. // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. @@ -45,10 +46,10 @@ mediaWiki.language.convertGrammar = function( word, form ) { ending = hyphen + jot + 'æн'; break; case 'allative': - ending = hyphen + end_allative; + ending = hyphen + endAllative; break; case 'ablative': - if ( jot == 'й' ) { + if ( jot === 'й' ) { ending = hyphen + jot + 'æ'; } else { diff --git a/resources/mediawiki.language/languages/ru.js b/resources/mediawiki.language/languages/ru.js index cfdbfc3b..1bc06326 100644 --- a/resources/mediawiki.language/languages/ru.js +++ b/resources/mediawiki.language/languages/ru.js @@ -2,27 +2,51 @@ * Russian (Русский) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'ru', 'grammarForms' ); +// These tests were originally made for names of Wikimedia +// websites, so they don't currently cover all the possible +// cases. + +mediaWiki.language.convertGrammar = function ( word, form ) { + 'use strict'; + + var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'genitive': // родительный падеж - if ( ( word.substr( word.length - 4 ) == 'вики' ) || ( word.substr( word.length - 4 ) == 'Вики' ) ) { - } - else if ( word.substr( word.length - 1 ) == 'ь' ) + if ( word.substr( word.length - 1 ) === 'ь' ) { word = word.substr(0, word.length - 1 ) + 'я'; - else if ( word.substr( word.length - 2 ) == 'ия' ) + } else if ( word.substr( word.length - 2 ) === 'ия' ) { word = word.substr(0, word.length - 2 ) + 'ии'; - else if ( word.substr( word.length - 2 ) == 'ка' ) + } else if ( word.substr( word.length - 2 ) === 'ка' ) { word = word.substr(0, word.length - 2 ) + 'ки'; - else if ( word.substr( word.length - 2 ) == 'ти' ) + } else if ( word.substr( word.length - 2 ) === 'ти' ) { word = word.substr(0, word.length - 2 ) + 'тей'; - else if ( word.substr( word.length - 2 ) == 'ды' ) + } else if ( word.substr( word.length - 2 ) === 'ды' ) { word = word.substr(0, word.length - 2 ) + 'дов'; - else if ( word.substr( word.length - 3 ) == 'ник' ) + } else if ( word.substr( word.length - 3 ) === 'ные' ) { + word = word.substr(0, word.length - 3 ) + 'ных'; + } else if ( word.substr( word.length - 3 ) === 'ник' ) { word = word.substr(0, word.length - 3 ) + 'ника'; + } + break; + case 'prepositional': // предложный падеж + if ( word.substr( word.length - 1 ) === 'ь' ) { + word = word.substr(0, word.length - 1 ) + 'е'; + } else if ( word.substr( word.length - 2 ) === 'ия' ) { + word = word.substr(0, word.length - 2 ) + 'ии'; + } else if ( word.substr( word.length - 2 ) === 'ка' ) { + word = word.substr(0, word.length - 2 ) + 'ке'; + } else if ( word.substr( word.length - 2 ) === 'ти' ) { + word = word.substr(0, word.length - 2 ) + 'тях'; + } else if ( word.substr( word.length - 2 ) === 'ды' ) { + word = word.substr(0, word.length - 2 ) + 'дах'; + } else if ( word.substr( word.length - 3 ) === 'ные' ) { + word = word.substr(0, word.length - 3 ) + 'ных'; + } else if ( word.substr( word.length - 3 ) === 'ник' ) { + word = word.substr(0, word.length - 3 ) + 'нике'; + } break; } return word; diff --git a/resources/mediawiki.language/languages/sl.js b/resources/mediawiki.language/languages/sl.js index acd00bfd..fb335b6a 100644 --- a/resources/mediawiki.language/languages/sl.js +++ b/resources/mediawiki.language/languages/sl.js @@ -2,10 +2,10 @@ * Slovenian (Slovenščina) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'sl', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + var grammarForms = mediaWiki.language.getData( 'sl', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'mestnik': // locative diff --git a/resources/mediawiki.language/languages/uk.js b/resources/mediawiki.language/languages/uk.js index ee110b06..5e56b66f 100644 --- a/resources/mediawiki.language/languages/uk.js +++ b/resources/mediawiki.language/languages/uk.js @@ -2,33 +2,35 @@ * Ukrainian (Українська) language functions */ -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mw.language.getData( 'uk', 'grammarForms' ); +mediaWiki.language.convertGrammar = function ( word, form ) { + /*jshint noempty:false */ + var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' ); if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] ; + return grammarForms[form][word]; } switch ( form ) { case 'genitive': // родовий відмінок - if ( ( word.substr( word.length - 4 ) == 'вікі' ) || ( word.substr( word.length - 4 ) == 'Вікі' ) ) { - } - else if ( word.substr( word.length - 1 ) == 'ь' ) + if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { + } else if ( word.substr( word.length - 1 ) === 'ь' ) { word = word.substr(0, word.length - 1 ) + 'я'; - else if ( word.substr( word.length - 2 ) == 'ія' ) + } else if ( word.substr( word.length - 2 ) === 'ія' ) { word = word.substr(0, word.length - 2 ) + 'ії'; - else if ( word.substr( word.length - 2 ) == 'ка' ) + } else if ( word.substr( word.length - 2 ) === 'ка' ) { word = word.substr(0, word.length - 2 ) + 'ки'; - else if ( word.substr( word.length - 2 ) == 'ти' ) + } else if ( word.substr( word.length - 2 ) === 'ти' ) { word = word.substr(0, word.length - 2 ) + 'тей'; - else if ( word.substr( word.length - 2 ) == 'ды' ) + } else if ( word.substr( word.length - 2 ) === 'ды' ) { word = word.substr(0, word.length - 2 ) + 'дов'; - else if ( word.substr( word.length - 3 ) == 'ник' ) + } else if ( word.substr( word.length - 3 ) === 'ник' ) { word = word.substr(0, word.length - 3 ) + 'ника'; + } break; case 'accusative': // знахідний відмінок - if ( ( word.substr( word.length - 4 ) == 'вікі' ) || ( word.substr( word.length - 4 ) == 'Вікі' ) ) { + if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { } - else if ( word.substr( word.length - 2 ) == 'ія' ) + else if ( word.substr( word.length - 2 ) === 'ія' ) { word = word.substr(0, word.length - 2 ) + 'ію'; + } break; } return word; diff --git a/resources/mediawiki.language/mediawiki.cldr.js b/resources/mediawiki.language/mediawiki.cldr.js index 6660eca4..c3023cd5 100644 --- a/resources/mediawiki.language/mediawiki.cldr.js +++ b/resources/mediawiki.language/mediawiki.cldr.js @@ -1,8 +1,8 @@ /** - * CLDR related utility methods + * CLDR related utility methods. */ -( function( mw ) { - "use strict"; +( function ( mw ) { + 'use strict'; var cldr = { /** @@ -10,19 +10,20 @@ * In case none of the rules passed, we return pluralRules.length * That means it is the "other" form. * @param number - * @param pluralRules - * @return plural form index + * @param {Array} pluralRules + * @return {number} plural form index */ - getPluralForm: function( number, pluralRules ) { - var pluralFormIndex = 0; - for ( pluralFormIndex = 0; pluralFormIndex < pluralRules.length; pluralFormIndex++ ) { - if ( mw.libs.pluralRuleParser( pluralRules[pluralFormIndex], number ) ) { + getPluralForm: function ( number, pluralRules ) { + var i; + for ( i = 0; i < pluralRules.length; i++ ) { + if ( mw.libs.pluralRuleParser( pluralRules[i], number ) ) { break; } } - return pluralFormIndex; + return i; } }; mw.cldr = cldr; -} )( mediaWiki ); + +}( mediaWiki ) ); diff --git a/resources/mediawiki.language/mediawiki.language.init.js b/resources/mediawiki.language/mediawiki.language.init.js index 30307a37..937b89bb 100644 --- a/resources/mediawiki.language/mediawiki.language.init.js +++ b/resources/mediawiki.language/mediawiki.language.init.js @@ -2,7 +2,7 @@ * Base language object with methods for storing and getting * language data. */ -( function ( mw, $ ) { +( function ( mw ) { var language = { /** @@ -58,4 +58,4 @@ mw.language = language; -}( mediaWiki, jQuery ) ); +}( mediaWiki ) ); diff --git a/resources/mediawiki.language/mediawiki.language.js b/resources/mediawiki.language/mediawiki.language.js index 935d4ff6..631d13df 100644 --- a/resources/mediawiki.language/mediawiki.language.js +++ b/resources/mediawiki.language/mediawiki.language.js @@ -43,12 +43,37 @@ var language = { * @param forms array List of plural forms * @return string Correct form for quantifier in this language */ - convertPlural: function( count, forms ) { - var pluralFormIndex = 0; + convertPlural: function ( count, forms ) { + var pluralRules, + formCount, + form, + index, + equalsPosition, + pluralFormIndex = 0; + if ( !forms || forms.length === 0 ) { return ''; } - var pluralRules = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'pluralRules' ); + + // Handle for explicit n= forms + for ( index = 0; index < forms.length; index++ ) { + form = forms[index]; + if ( /^\d+=/.test( form ) ) { + equalsPosition = form.indexOf( '=' ); + formCount = parseInt( form.substring( 0, equalsPosition ), 10 ); + if ( formCount === count ) { + return form.substr( equalsPosition + 1 ); + } + forms[index] = undefined; + } + } + + // Remove explicit plural forms from the forms. + forms = $.map( forms, function ( form ) { + return form; + } ); + + pluralRules = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'pluralRules' ); if ( !pluralRules ) { // default fallback. return ( count === 1 ) ? forms[0] : forms[1]; @@ -73,43 +98,6 @@ var language = { }, /** - * Converts a number using digitTransformTable. - * - * @param {num} number Value to be converted - * @param {boolean} integer Convert the return value to an integer - */ - convertNumber: function( num, integer ) { - var i, tmp, transformTable; - - if ( !mw.language.digitTransformTable ) { - return num; - } - // Set the target Transform table: - transformTable = mw.language.digitTransformTable; - // Check if the "restore" to Latin number flag is set: - if ( integer ) { - if ( parseInt( num, 10 ) === num ) { - return num; - } - tmp = []; - for ( i in transformTable ) { - tmp[ transformTable[ i ] ] = i; - } - transformTable = tmp; - } - var numberString = '' + num; - var convertedNumber = ''; - for ( i = 0; i < numberString.length; i++ ) { - if ( transformTable[ numberString[i] ] ) { - convertedNumber += transformTable[numberString[i]]; - } else { - convertedNumber += numberString[i]; - } - } - return integer ? parseInt( convertedNumber, 10 ) : convertedNumber; - }, - - /** * Provides an alternative text depending on specified gender. * Usage {{gender:[gender|user object]|masculine|feminine|neutral}}. * If second or third parameter are not specified, masculine is used. @@ -121,7 +109,7 @@ var language = { * * @return string */ - gender: function( gender, forms ) { + gender: function ( gender, forms ) { if ( !forms || forms.length === 0 ) { return ''; } @@ -151,10 +139,8 @@ var language = { return grammarForms[form][word] || word; } return word; - }, + } - // Digit Transform Table, populated by language classes where applicable - digitTransformTable: mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'digitTransformTable' ) }; $.extend( mw.language, language ); diff --git a/resources/mediawiki.language/mediawiki.language.months.js b/resources/mediawiki.language/mediawiki.language.months.js new file mode 100644 index 00000000..3d4b7ee7 --- /dev/null +++ b/resources/mediawiki.language/mediawiki.language.months.js @@ -0,0 +1,54 @@ +/** + * Transfer of month names from messages into mw.language. + * + * Loading this module also ensures the availability of appropriate messages via mw.msg. + */ +( function ( mw, $ ) { + var + monthMessages = [ + 'january', 'february', 'march', 'april', + 'may_long', 'june', 'july', 'august', + 'september', 'october', 'november', 'december' + ], + monthGenMessages = [ + 'january-gen', 'february-gen', 'march-gen', 'april-gen', + 'may-gen', 'june-gen', 'july-gen', 'august-gen', + 'september-gen', 'october-gen', 'november-gen', 'december-gen' + ], + monthAbbrevMessages = [ + 'jan', 'feb', 'mar', 'apr', + 'may', 'jun', 'jul', 'aug', + 'sep', 'oct', 'nov', 'dec' + ]; + + // Function suitable for passing to jQuery.map + // Can't use mw.msg directly because jQuery.map passes element index as second argument + function mwMsgMapper( key ) { + return mw.msg( key ); + } + + /** + * Information about month names in current UI language. + * + * Object keys: + * - `names`: array of month names (in nominative case in languages which have the distinction), + * zero-indexed + * - `genitive`: array of month names in genitive case, zero-indexed + * - `abbrev`: array of three-letter-long abbreviated month names, zero-indexed + * - `keys`: object with three keys like the above, containing zero-indexed arrays of message keys + * for appropriate messages which can be passed to mw.msg. + * + * @property + */ + mw.language.months = { + keys: { + names: monthMessages, + genitive: monthGenMessages, + abbrev: monthAbbrevMessages + }, + names: $.map( monthMessages, mwMsgMapper ), + genitive: $.map( monthGenMessages, mwMsgMapper ), + abbrev: $.map( monthAbbrevMessages, mwMsgMapper ) + }; + +}( mediaWiki, jQuery ) ); diff --git a/resources/mediawiki.language/mediawiki.language.numbers.js b/resources/mediawiki.language/mediawiki.language.numbers.js new file mode 100644 index 00000000..fada6ce1 --- /dev/null +++ b/resources/mediawiki.language/mediawiki.language.numbers.js @@ -0,0 +1,243 @@ +/* + * Number related utilities for mediawiki.language + */ +( function ( mw, $ ) { + + /** + * Pad a string to guarantee that it is at least `size` length by + * filling with the character `ch` at either the start or end of the + * string. Pads at the start, by default. + * example: + * Fill the string to length 10 with '+' characters on the right. Yields 'blah++++++'. + * pad('blah', 10, '+', true); + * + * @param {string} text The string to pad + * @param {Number} size To provide padding + * @param {string} ch Character to pad, defaults to '0' + * @param {Boolean} end Adds padding at the end if true, otherwise pads at start + * @return {string} + */ + function pad ( text, size, ch, end ) { + if ( !ch ) { + ch = '0'; + } + + var out = String( text ), + padStr = replicate( ch, Math.ceil( ( size - out.length ) / ch.length ) ); + + return end ? out + padStr : padStr + out; + } + + /** + * Efficiently replicate a string n times. + * + * @param {string} str The string to replicate + * @param {Number} num Number of times to replicate the string + * @return {string} + */ + function replicate ( str, num ) { + if ( num <= 0 || !str ) { + return ''; + } + + var buf = []; + while (num) { + buf.push( str ); + str += str; + } + return buf.join( '' ); + } + + /** + * Apply numeric pattern to absolute value using options. Gives no + * consideration to local customs. + * + * Adapted from dojo/number library with thanks + * http://dojotoolkit.org/reference-guide/1.8/dojo/number.html + * + * @param {Number} value the number to be formatted, ignores sign + * @param {string} pattern the number portion of a pattern (e.g. `#,##0.00`) + * @param {string} options.decimalThe decimal separator + * @param {string} options.group The group separator + * + * @return {string} + */ + function commafyNumber( value, pattern, options ) { + options = options || { + group: ',', + decimal: '.' + }; + + if ( isNaN( value) ) { + return value; + } + + var padLength, + patternDigits, + index, + whole, + off, + remainder, + patternParts = pattern.split( '.' ), + maxPlaces = ( patternParts[1] || [] ).length, + valueParts = String( Math.abs( value ) ).split( '.' ), + fractional = valueParts[1] || '', + groupSize = 0, + groupSize2 = 0, + pieces = []; + + if ( patternParts[1] ) { + // Pad fractional with trailing zeros + padLength = ( patternParts[1] && patternParts[1].lastIndexOf( '0' ) + 1 ); + + if ( padLength > fractional.length ) { + valueParts[1] = pad( fractional, padLength, '0', true ); + } + + // Truncate fractional + if ( maxPlaces < fractional.length ) { + valueParts[1] = fractional.substr( 0, maxPlaces ); + } + } else { + if ( valueParts[1] ) { + valueParts.pop(); + } + } + + // Pad whole with leading zeros + patternDigits = patternParts[0].replace( ',', '' ); + + padLength = patternDigits.indexOf( '0' ); + + if ( padLength !== -1 ) { + padLength = patternDigits.length - padLength; + + if ( padLength > valueParts[0].length ) { + valueParts[0] = pad( valueParts[0], padLength ); + } + + // Truncate whole + if ( patternDigits.indexOf( '#' ) === -1 ) { + valueParts[0] = valueParts[0].substr( valueParts[0].length - padLength ); + } + } + + // Add group separators + index = patternParts[0].lastIndexOf( ',' ); + + if ( index !== -1 ) { + groupSize = patternParts[0].length - index - 1; + remainder = patternParts[0].substr( 0, index ); + index = remainder.lastIndexOf( ',' ); + if ( index !== -1 ) { + groupSize2 = remainder.length - index - 1; + } + } + + for ( whole = valueParts[0]; whole; ) { + off = whole.length - groupSize; + + pieces.push( ( off > 0 ) ? whole.substr( off ) : whole ); + whole = ( off > 0 ) ? whole.slice( 0, off ) : ''; + + if ( groupSize2 ) { + groupSize = groupSize2; + } + } + valueParts[0] = pieces.reverse().join( options.group ); + + return valueParts.join( options.decimal ); + } + + $.extend( mw.language, { + + /** + * Converts a number using digitTransformTable. + * + * @param {Number} num Value to be converted + * @param {boolean} integer Convert the return value to an integer + * @return {Number|string} Formatted number + */ + convertNumber: function ( num, integer ) { + var i, tmp, transformTable, numberString, convertedNumber, pattern; + + pattern = mw.language.getData( mw.config.get( 'wgUserLanguage' ), + 'digitGroupingPattern' ) || '#,##0.###'; + + // Set the target transform table: + transformTable = mw.language.getDigitTransformTable(); + + if ( !transformTable ) { + return num; + } + + // Check if the 'restore' to Latin number flag is set: + if ( integer ) { + if ( parseInt( num, 10 ) === num ) { + return num; + } + tmp = []; + for ( i in transformTable ) { + tmp[ transformTable[ i ] ] = i; + } + transformTable = tmp; + numberString = num + ''; + } else { + numberString = mw.language.commafy( num, pattern ); + } + + convertedNumber = ''; + for ( i = 0; i < numberString.length; i++ ) { + if ( transformTable[ numberString[i] ] ) { + convertedNumber += transformTable[numberString[i]]; + } else { + convertedNumber += numberString[i]; + } + } + return integer ? parseInt( convertedNumber, 10 ) : convertedNumber; + }, + + getDigitTransformTable: function () { + return mw.language.getData( mw.config.get( 'wgUserLanguage' ), + 'digitTransformTable' ) || []; + }, + + getSeparatorTransformTable: function () { + return mw.language.getData( mw.config.get( 'wgUserLanguage' ), + 'separatorTransformTable' ) || []; + }, + + /** + * Apply pattern to format value as a string using as per + * unicode.org TR35 - http://www.unicode.org/reports/tr35/#Number_Format_Patterns. + * + * @param {Number} value + * @param {string} pattern Pattern string as described by Unicode TR35 + * @throws Error + * @returns {String} + */ + commafy: function ( value, pattern ) { + var numberPattern, + transformTable = mw.language.getSeparatorTransformTable(), + group = transformTable[','] || ',', + numberPatternRE = /[#0,]*[#0](?:\.0*#*)?/, // not precise, but good enough + decimal = transformTable['.'] || '.', + patternList = pattern.split( ';' ), + positivePattern = patternList[0]; + + pattern = patternList[ ( value < 0 ) ? 1 : 0] || ( '-' + positivePattern ); + numberPattern = positivePattern.match( numberPatternRE ); + + if ( !numberPattern ) { + throw new Error( 'unable to find a number expression in pattern: ' + pattern ); + } + + return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[0], { + decimal: decimal, + group: group + } ) ); + } + + } ); + +}( mediaWiki, jQuery ) ); |