Commit graph

1262 commits

Author SHA1 Message Date
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
Sam Reed
b94e65c4dc Fix 0bps or less
r107744
2011-12-31 21:57:47 +00:00
Sam Reed
effbf865a9 Fixup r107744, r107743 2011-12-31 21:54:28 +00:00
Sam Reed
3bbfb9844a Followup r107743, use messages in formatBitrate
Add method description
2011-12-31 21:32:42 +00:00
Sam Reed
88bd0f7b0e Fail, fix Ypbs from r107735 2011-12-31 20:36:43 +00:00
Sam Reed
a9d2474110 bug 33014 and r107734
Add Tbps through Ybps (yay for code that just works (tm))
2011-12-31 20:35:35 +00:00
Sam Reed
3b06d6fbc9 Followup r106791, r107692 and bug 33014
Make Language::formatNum() handle  TB through YB

Rewrote code to be simpler and less indenty

Though, something like formatBitrate might be be better in future... We'll see!
2011-12-31 20:20:15 +00:00
Niklas Laxström
40868de594 Whitespace 2011-12-25 12:32:41 +00:00
Robin Pepermans
24b83d2d68 @since for r99863 2011-12-25 02:54:02 +00:00
Brion Vibber
c1906d53de Provisional revert r106573, r106559: may be the wrong thing to do, and should probably come with regression tests if added. 2011-12-20 21:24:06 +00:00
Robin Pepermans
e9033cbf82 Follow-up r106559: it's better to set the preference for own MediaWiki names in Language::getTranslatedLanguageNames. More consistent and saves some code :)
Also update Babel to use that function.
2011-12-18 17:58:47 +00:00
Robin Pepermans
c3df917edb Clarify documentation 2011-12-18 13:50:34 +00:00
Platonides
351729ac15 Remove unneeded global
https://gerrit.wikimedia.org/r/#change,1571
2011-12-15 20:43:58 +00:00
Brion Vibber
f1ce2ce952 * (bug 32461) Add two-digit short form year for Persian calendar ({{#time:xiy}})
Patch by Platonides https://bugzilla.wikimedia.org/attachment.cgi?id=9490&action=diff
Plus test case. Note the test case uses Latin-style digits because it's testing English; in fa you'd get the persian digits as in the examples on the bug.
2011-12-14 00:32:56 +00:00
Brion Vibber
832dac129a bug 33035: Followup r105925: set to null rather than unset so we don't get an undefined property error later
Apparently the unset() in Language::setCode() could cause the later is_null check in getHtmlCode() to fail, though I could not reproduce it myself.
2011-12-13 19:58:44 +00:00
Sam Reed
6e2acfd778 Public for all 2011-12-13 15:40:15 +00:00
Daniel Friesen
85a70f60e1 Followup r105812:
- Fix case of the wfBCP47 call
- Don't call wfBCP47 for every time getHtmlCode is called
- Add @since
2011-12-12 20:09:06 +00:00
Daniel Friesen
9d0ee321b6 Introduce a Language::getMessagesFileName hook that will allow extensions to define new language messages files outside of core. 2011-12-12 19:32:59 +00:00
Daniel Friesen
42e8b0a8e7 Replace get{Local,Full,Link,Canonical}URL's $variant argument with a secondary $query argument and treat variant paths like we do action paths. 2011-12-12 19:19:23 +00:00