Commit graph

1280 commits

Author SHA1 Message Date
Alexandre Emsenhuber
52aa2aaba1 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ie60ee0a8137d750a66892ea5b0cc751c74d662f9
2012-06-05 22:18:51 +02:00
Siebrand
8a73db81a7 Merge "(bug 36819) Make language names lowercase first letter where usual" 2012-06-02 09:59:45 +00:00
Reedy
912c309987 Merge "(bug 37194) remove obsoletes *.deps.php" 2012-05-31 13:54:00 +00:00
lupo
5b9731e08a (bug 36839) Use mb_check_encoding() if available.
This is not a real fix for the cause of the bug (which is a
pcre.recursion_limit that is far too low), but I do wonder
about the efficiency of using a regexp to test for valid
UTF-8 encoding. After all the regexp has to be compiled first
into a state machine.

Patch set 2: Php unit test for Language.checkTitleEncoding
Patch set 3: benchmark
Patch set 4: add benchmark for non-capturing subgroup in regexp, and
since that's faster than a capturing subgroup, use it in
checkTitleEncoding() in the regexp branch.
Patch set 5: use Tim's suggestion (once-only pattern) in the regexp
branch. Also add to benchmark.

Change-Id: I551f096921d4c9c57cbcb091b80ab5970ca86a9b
2012-05-31 14:21:36 +02:00
Antoine Musso
0ec77e2b31 (bug 37194) remove obsoletes *.deps.php
PHP had a nasty bug related to late/early binding and referenced at
https://bugs.php.net/bug.php?id=56776 . The workaround was to add some
.deps.php files to make sure code is loaded early.

Upstream PHP issue #56778 was fixed in PHP 5.1.

See also:
http://lists.wikimedia.org/pipermail/wikitech-l/2006-January/021311.html

Change-Id: I4c85f65c6b5f3df3218bb107881547d44f0cf107
2012-05-29 14:05:03 +02:00
Nikerabbit
fccc2f1b8b Merge "Revert "Remove old compat methods/functions for mb_ functions"" 2012-05-28 13:34:12 +00:00
Reedy
246a7dd6b9 Revert "Remove old compat methods/functions for mb_ functions"
mb_ functions are in an extension, but apparently not enabled/compiled in by default. Safer to just keep these around till it maybe happens in the future

This reverts commit 1497bd1f36
2012-05-28 12:55:31 +00:00
Aaron Schulz
4acf38255f Merge "Remove old compat methods/functions for mb_ functions" 2012-05-27 16:33:39 +00:00
Reedy
1497bd1f36 Remove old compat methods/functions for mb_ functions
PHP docs suggest all were added well before our minimum version, and as such should exist

Change-Id: I6921b1374df0b997b3519699556528973882565a
2012-05-27 13:10:08 +01:00
robin
1d5e7642d0 (bug 36819) Make language names lowercase first letter where usual
Change the first letter of language names in Names.php lowercase where this is usual in the spelling, for most languages based on what I know, Wikipedia and CLDR. This makes them more consistent with CLDR.
Change Language::fetchLanguageNames() so these MediaWiki names are always used, and so CLDR names do not override them when using $inLanguage.

Change-Id: I7b41b978a309c40e0210f2a295d3cba65cd5ec4e
2012-05-26 17:48:17 +02:00
Amir E. Aharoni
945ff2f4aa Adding params to getArrow()
Adding params to getArrow, backwards, left, right, up, down.

Change-Id: Ifbcffca71c495a627d69edd36fec389ceb68bb80
2012-05-21 16:22:57 +03:00
Aaron
5ef42e2c10 Fixed undefined var notice.
* Fixed "Notice: Undefined variable: addmsg in /var/www/TrunkWiki/core/languages/Language.php on line 254"

Change-Id: Ib5fa6b7c1137f24bc998249af72eaf7301a2aaa8
2012-05-18 15:19:16 -07:00
Aaron Schulz
d8f056aebf Merge "(bug 36908) Language::isValidBuiltInCode passed an object" 2012-05-18 21:50:35 +00:00
Antoine Musso
120a3f2b60 (bug 36908) Language::isValidBuiltInCode passed an object
This make isValidBuiltInCode to throw an exception whenever it is passed
something which is not a string.  The rational being to easily find out
errors when the method is wrongly used.

An alternative would be to detect the object being passed is a Language
object and get its Language code.

Change-Id: I37cc419cc725df8d8022e619d8f5191f58a8fd5e
2012-05-18 08:40:17 +02:00
robin
aed0328558 fetchLanguageNames: fallback to default instead of false
In Language::fetchLanguageNames, fallback to the default option (mw) instead of returning false if none of the three options (all/mw/mwfile) is recognized

Change-Id: I743540bb0d1e7572a5a7e2f4ed9b57e7552d99b2
2012-05-10 21:30:59 +02:00
Jeroen De Dauw
77d2f16760 duration formatter, makes time in sec easy to read
The Language::formatDuration() method introduced by this patch let us
easily render an amount of seconds for easier human reading.

 $ maintenance/eval.php
 > var_dump( $wgLang->formatDuration( 1000 );
 string(25) "16 minutes and 40 seconds"

Also ran rebuildLanguage.php on Siebrands request

Change-Id: If287fb10e897d3d2374cf6eeae3bc5be00cdfc01
2012-04-13 13:54:04 +02:00
Santhosh Thottingal
931c31c7bd (bug 33658) support for {{GRAMMAR:}} in jqueryMsg
This add GRAMMAR support to the mediawiki.jqueryMsg module:

1. make jqueryMsg understand GRAMMAR(case insensitive)
2. mw.language get convertGrammar, can be overridden per language as in
   php
3. Introduce resourceloader module ResourceLoaderLanguageDataModule
4. Language.php get a method to filter wgGrammerForms for the current
   contentLanguage.
5. Qunit tests
6. This code was originally written in jsgrammar branch of svn and had
   reviewed during the last slush time.

Change-Id: I90dd0b2f0cb30fd30539896c292829adc4fc7364
2012-04-10 11:47:39 +02:00
Reedy
76e2f41be4 $rootCode isn't used so no point creating it
Change-Id: I1c71e8bc1952bac2b5c9a81b4d3e6e4174979b38
2012-04-07 21:21:23 +01:00
Amir E. Aharoni
b2b3075afd Adding getDirMarkEntity().
This function is similar to getDirMark(), but it adds HTML entities
instead of invisible Unicode characters.

It's based on MaxSem's suggestion in
https://gerrit.wikimedia.org/r/#change,3929

Change-Id: I5bd362d6e6a56478bf9f58b2b81fcad31be12d35
2012-03-31 13:19:37 +03:00
Sam Reed
c27fbf5330 Trim trailing whitespace
Add/improve documentation

Explicitly define a few variables

Change-Id: If0017770a0a47f8f6be178b5bde8ae6691f74b6a
2012-03-21 15:47:05 -07:00
Roan Kattouw
311200ee2c Revert r114067, r114071, r114075, r114079, r114081, r114082, r114084, r114086, r114088, r114089, r114101, r114118, r114137, r114147, r114164, r114172, r114175, r114180, r114208, r114209, r114215, r114219, r114226, r114321, r114322.
This reverts the SpecialCachedPage and formatDuration sagas, with some collateral damage here and there. All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
2012-03-20 23:03:59 +00:00
Jeroen De Dauw
4bb8ef8a82 handle cases where an empty array is provided by using this as default, also correctly handle cases where the smallest unit is not the second and the result is 0 smallestunit 2012-03-20 22:47:50 +00:00
Sam Reed
a2dc33a5a3 Trim trailing whitespace
Add/improve documentation

Explicitly define a few variables
2012-03-17 22:52:54 +00:00
Sam Reed
d6389e76c8 Followup r114067 rename to formatDuration to match other methods 2012-03-17 22:26:26 +00:00
Sam Reed
6d590e06da Followup r114067
Add centuries because the messages were already there but not used

Add decade and millennia for the luls/completeness
2012-03-17 22:14:44 +00:00
Jeroen De Dauw
cbdee4b668 follow up to r114067, use correct language 2012-03-17 21:47:17 +00:00
Jeroen De Dauw
9d4049a0ce adding a duration function to language that converts seconds to text 2012-03-17 20:58:46 +00:00
Robin Pepermans
b539f7a98e Follow-up r112479
* Add @since, fix indentation.
* Change default from 'all' to 'mw' as it's the most used (so default fetchLanguageNames() is equivalent to default getLanguageNames()).
* Add the include parameter also to fetchLanguageName() as it's needed in Parser: interlanguage links should only take into account mediawiki names. (Doesn't make a difference with how the functions are now, but could have been later.)
2012-03-08 19:30:30 +00:00
Sam Reed
dedc5a1613 Add to documentation
Add a couple of braces

Update code calling Language related deprecated code
2012-03-05 19:17:55 +00:00
Sam Reed
d8b5f703b1 Fix missing * from start of comment block
Also minor documentation update
2012-03-05 00:05:31 +00:00
Aaron Schulz
addb104444 Added FIXME to formatExpiry() 2012-03-03 11:16:30 +00:00
Robin Pepermans
44d2c73bf5 Combine getLanguageNames and getTranslatedLanguageNames into one function which is much easier and more logical to use. Does not contain any actual changes yet in what the function does.
* Reduces the overly long code in r107002, and reduces code for {{#language:}}
* Fixes the language list in Special:Translate which contained languages that gave "invalid code" when selecting
2012-02-27 11:59:24 +00:00
Sam Reed
6488754dad More documentation improvements 2012-02-09 21:17:18 +00:00
Tim Starling
a444986c45 * Optimise {{GENDER}} so that it doesn't need to load the user options if only one form is given. For some reason (presumably some detail of how translatewiki.net works) such {{GENDER}} invocations are extremely common.
* Updated Language::gender() documentation accordingly
2012-02-08 06:09:58 +00:00
Mark A. Hershberger
2d72930472 w/s 2012-02-07 13:05:31 +00:00
Antoine Musso
fc6bc233be Fix doxygen docs before REL1_19 branching 2012-02-01 20:53:38 +00:00
Antoine Musso
c165d61eb4 @since for r105919 (hasVariant / getConverter) 2012-01-30 08:10:19 +00:00
Max Semenik
cbb4b4716d Add function present in ordinary converter to FakeConverter 2012-01-29 12:49:14 +00:00
Chad Horohoe
e8da212569 Fixup r109698, add setter for $namespaceNames and use proper accessors in the tests.
Since we're here: nothing uses $namespaceNames, $mNamespaceIds or $namespaceAliases
outside of this class (core or extensions) so lets make it protected.
2012-01-27 13:00:26 +00:00
Krinkle
4790826b97 [Unit testing] Add unit tests for Xml::namespaceSelector
* Making Language::namespaceNames explicitly public. It already was but since is being used as such outside the class
2012-01-21 22:26:14 +00:00
Antoine Musso
9cccde6485 method documentation for r108364
The function are badly named and could use something better :D
2012-01-09 14:10:13 +00:00
Sam Reed
a58a8cd8b4 Fix str_replace parameter order fail from r108364 2012-01-08 20:44:23 +00:00
Sam Reed
e6f1ac4f5b Followup r108363 for bug 33571
Refactor out duplicate code
2012-01-08 20:40:13 +00:00
Brion Vibber
9e77c61850 * bug 33571: fix yottabits/s in Language::formatBitrate
Problem was caused by inexact floating-point comparisons with values returned from
log10(); worked around by simply duplicating the very similar code in the function
immediately below, which does the same thing with 1024 instead of 1000 unit sizes,
uses only simple division, and passes the test cases.
2012-01-08 20:15:08 +00:00
Antoine Musso
36f6e560ec rv r108284 since PHP has different behaviors
should fix jenkins
2012-01-06 22:18:46 +00:00
Antoine Musso
c6fc4a01b8 Fix formatBitrate behavior on Mac OS X
Language::formatBitrate() uses log10() to makes a long number human readeable.
There is a nasty rounding error on Mac OS X for log10():

 log10(pow(10,15)) => gives 15

 floor( log10(pow(10,15)) ) => gives 14 (should be 15)

The end result is that pow(10,15) is formatted as 1,000Tbps instead of 1Pbps

log( $foo, 10) does not suffer from this:

 php -r 'print floor(log(pow(10,15),10)) ."\n";'

PHP Version used:

 $ php -v
 PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep  8 2011 19:34:00)
 Copyright (c) 1997-2011 The PHP Group
 Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
     with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
 $

TEST PLAN:

BEFORE
======

$ php phpunit.php ./languages/LanguageTest.php 
PHPUnit 3.6.3 by Sebastian Bergmann.

...............................................................  63 / 170 ( 37%)
............................................................... 126 / 170 ( 74%)
.......................................F....

Time: 2 seconds, Memory: 32.25Mb

There was 1 failure:

1) LanguageTest::testFormatBitrate with data set #5 (1000000000000000, '1Pbps', '1 petabit per second')
formatBitrate('1000000000000000'): 1 petabit per second
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1Pbps'
+'1,000Tbps'

FAILURES!
Tests: 170, Assertions: 174, Failures: 1.


AFTER
=====

PHPUnit 3.6.3 by Sebastian Bergmann.

...............................................................  63 / 170 ( 37%)
............................................................... 126 / 170 ( 74%)
............................................

Time: 1 second, Memory: 32.25Mb

OK (170 tests, 174 assertions)
2012-01-06 21:49:55 +00:00
Santhosh Thottingal
1fb1fae9a2 Stylize. 2012-01-04 09:06:05 +00:00
Santhosh Thottingal
ad13e54f84 Address an edge case - input being null. Add test cases. 2012-01-04 08:56:36 +00:00
Brian Wolff
39d808f8e0 (Half of bug 33454) The week based year number (format char 'o') was being calculated based on server timezone instead of UTC in sprintfDate. [follow-up r45208]
This would cause a couple incorrect results on new years day.
2012-01-02 08:20:03 +00:00
Sam Reed
cea7c863e5 Prevent undefined offset when formatBitrate is given a significantly large enough number (10^27)
> echo $wgLang->formatBitrate( pow( 10, 27 ) );
PHP Notice:  Undefined offset: 9 in /home/reedy/mediawiki/trunk/phase3/languages/Language.php on line 3827
PHP Stack trace:
PHP   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
PHP   2. eval() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:82
PHP   3. Language->formatBitrate() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(82) : eval()'d code:1

Notice: Undefined offset: 9 in /home/reedy/mediawiki/trunk/phase3/languages/Language.php on line 3827

Call Stack:
    0.0006     650736   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
   61.6539   21593432   2. eval(''echo $wgLang->formatBitrate( pow( 10, 27 ) );;'') /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:82
   61.6540   21593512   3. Language->formatBitrate() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(82) : eval()'d code:1

1bps
2011-12-31 22:53:50 +00:00